dsh-agent-enhancer 0.3.6 → 0.3.8
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/README.en.md +5 -4
- package/README.md +6 -5
- package/lib/client/dsh/settings-catalog.d.ts +2 -2
- package/lib/client/dsh/settings-catalog.d.ts.map +1 -1
- package/lib/client/dsh/settings-features.d.ts +2 -2
- package/lib/client/dsh/settings-features.d.ts.map +1 -1
- package/lib/client/dsh/settings.d.ts.map +1 -1
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/instructions-skills/errors.d.ts +4 -0
- package/lib/client/instructions-skills/errors.d.ts.map +1 -1
- package/lib/client/instructions-skills/install-progress-ui.d.ts +6 -0
- package/lib/client/instructions-skills/install-progress-ui.d.ts.map +1 -0
- package/lib/client/instructions-skills/remote.d.ts +4 -1
- package/lib/client/instructions-skills/remote.d.ts.map +1 -1
- package/lib/client/instructions-skills/tab.d.ts +7 -0
- package/lib/client/instructions-skills/tab.d.ts.map +1 -1
- package/lib/client/locales.d.ts +79 -27
- package/lib/client/locales.d.ts.map +1 -1
- package/lib/client/remote.d.ts +7 -1
- package/lib/client/remote.d.ts.map +1 -1
- package/lib/client/run-alerts/copy.d.ts +4 -0
- package/lib/client/run-alerts/copy.d.ts.map +1 -0
- package/lib/client/run-alerts/dedupe.d.ts +14 -0
- package/lib/client/run-alerts/dedupe.d.ts.map +1 -0
- package/lib/client/run-alerts/deliver.d.ts +16 -0
- package/lib/client/run-alerts/deliver.d.ts.map +1 -0
- package/lib/client/run-alerts/detect.d.ts +12 -0
- package/lib/client/run-alerts/detect.d.ts.map +1 -0
- package/lib/client/run-alerts/gate.d.ts +25 -0
- package/lib/client/run-alerts/gate.d.ts.map +1 -0
- package/lib/client/run-alerts/host.d.ts +29 -0
- package/lib/client/run-alerts/host.d.ts.map +1 -0
- package/lib/client/run-alerts/pending-kind.d.ts +4 -0
- package/lib/client/run-alerts/pending-kind.d.ts.map +1 -0
- package/lib/client/run-alerts/types.d.ts +21 -0
- package/lib/client/run-alerts/types.d.ts.map +1 -0
- package/lib/client.js +942 -139
- package/lib/client.js.map +1 -1
- package/lib/config.d.ts +6 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/host/index.d.ts +12 -2
- package/lib/host/index.d.ts.map +1 -1
- package/lib/host/instructions-skills/discover.d.ts.map +1 -1
- package/lib/host/instructions-skills/fs-access.d.ts +8 -0
- package/lib/host/instructions-skills/fs-access.d.ts.map +1 -0
- package/lib/host/instructions-skills/github-archive.d.ts +4 -1
- package/lib/host/instructions-skills/github-archive.d.ts.map +1 -1
- package/lib/host/instructions-skills/install-fs.d.ts +7 -2
- package/lib/host/instructions-skills/install-fs.d.ts.map +1 -1
- package/lib/host/instructions-skills/install-progress.d.ts +23 -0
- package/lib/host/instructions-skills/install-progress.d.ts.map +1 -0
- package/lib/host/instructions-skills/install.d.ts +8 -2
- package/lib/host/instructions-skills/install.d.ts.map +1 -1
- package/lib/host/instructions-skills/io.d.ts +5 -0
- package/lib/host/instructions-skills/io.d.ts.map +1 -1
- package/lib/host/instructions-skills/remove-path.d.ts +15 -0
- package/lib/host/instructions-skills/remove-path.d.ts.map +1 -1
- package/lib/host/instructions-skills/transient-paths.d.ts +15 -0
- package/lib/host/instructions-skills/transient-paths.d.ts.map +1 -0
- package/lib/host/instructions-skills/types.d.ts +15 -1
- package/lib/host/instructions-skills/types.d.ts.map +1 -1
- package/lib/host/instructions-skills/uninstall.d.ts +6 -0
- package/lib/host/instructions-skills/uninstall.d.ts.map +1 -1
- package/lib/host/instructions-skills/zip-install.d.ts.map +1 -1
- package/lib/host/rpc.d.ts +42 -0
- package/lib/host/rpc.d.ts.map +1 -1
- package/lib/host/run-alerts/notify.d.ts +39 -0
- package/lib/host/run-alerts/notify.d.ts.map +1 -0
- package/lib/identity.d.ts +1 -1
- package/lib/index.js +1058 -354
- package/lib/index.js.map +4 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/host/index.ts
|
|
2
|
-
import { existsSync as
|
|
3
|
-
import { homedir as
|
|
4
|
-
import { join as
|
|
2
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync9, readdirSync as readdirSync7, renameSync as renameSync8, rmdirSync } from "node:fs";
|
|
3
|
+
import { homedir as homedir5 } from "node:os";
|
|
4
|
+
import { join as join30 } from "node:path";
|
|
5
5
|
import z5 from "@deepseek-ai/schemastery";
|
|
6
6
|
import { RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
7
7
|
|
|
@@ -10,6 +10,16 @@ var AUTO_PROVIDER = "agent-enhancer";
|
|
|
10
10
|
var AUTO_MODEL = "auto";
|
|
11
11
|
|
|
12
12
|
// src/config.ts
|
|
13
|
+
function resolveRunAlertsLevel(value) {
|
|
14
|
+
switch (value) {
|
|
15
|
+
case "hidden":
|
|
16
|
+
case "unfocused":
|
|
17
|
+
case "always":
|
|
18
|
+
return value;
|
|
19
|
+
default:
|
|
20
|
+
return "unfocused";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
13
23
|
var DEFAULT_AUXILIARY_MODEL = {
|
|
14
24
|
provider: "",
|
|
15
25
|
model: "",
|
|
@@ -26,6 +36,8 @@ var DEFAULT_SETTINGS = {
|
|
|
26
36
|
sessionDeleteEnabled: true,
|
|
27
37
|
fileEditEnabled: true,
|
|
28
38
|
softPauseEnabled: true,
|
|
39
|
+
runAlertsEnabled: true,
|
|
40
|
+
runAlertsLevel: "unfocused",
|
|
29
41
|
instructionsSkillsEnabled: true,
|
|
30
42
|
mcpConnectorsEnabled: true,
|
|
31
43
|
optimizeProvider: "",
|
|
@@ -66,6 +78,8 @@ function resolveSettings(value) {
|
|
|
66
78
|
sessionDeleteEnabled: value?.sessionDeleteEnabled ?? true,
|
|
67
79
|
fileEditEnabled: value?.fileEditEnabled ?? true,
|
|
68
80
|
softPauseEnabled: value?.softPauseEnabled ?? true,
|
|
81
|
+
runAlertsEnabled: value?.runAlertsEnabled ?? true,
|
|
82
|
+
runAlertsLevel: resolveRunAlertsLevel(value?.runAlertsLevel),
|
|
69
83
|
instructionsSkillsEnabled: value?.instructionsSkillsEnabled ?? true,
|
|
70
84
|
mcpConnectorsEnabled: value?.mcpConnectorsEnabled ?? true,
|
|
71
85
|
optimizeProvider: text(value?.optimizeProvider),
|
|
@@ -181,7 +195,7 @@ var AuxiliaryError = class extends Error {
|
|
|
181
195
|
// src/identity.ts
|
|
182
196
|
var PACKAGE_NAME = "dsh-agent-enhancer";
|
|
183
197
|
var PLUGIN_ID = "agent-enhancer";
|
|
184
|
-
var PACKAGE_VERSION = "0.3.
|
|
198
|
+
var PACKAGE_VERSION = "0.3.8";
|
|
185
199
|
var LEGACY_PACKAGE_NAME = "dsh-composer-enhancer";
|
|
186
200
|
var ROLLBACK_PREFIX = `${PACKAGE_NAME}:rollback:`;
|
|
187
201
|
var UNDO_PREFIX = `${PACKAGE_NAME}:undo:`;
|
|
@@ -3632,7 +3646,7 @@ async function removePathBestEffort(path) {
|
|
|
3632
3646
|
return true;
|
|
3633
3647
|
} catch {
|
|
3634
3648
|
if (attempt === 2) return false;
|
|
3635
|
-
await new Promise((
|
|
3649
|
+
await new Promise((resolve16) => setTimeout(resolve16, 120 * (attempt + 1)));
|
|
3636
3650
|
}
|
|
3637
3651
|
}
|
|
3638
3652
|
return false;
|
|
@@ -4639,8 +4653,8 @@ function installMonacoRoute(ctx) {
|
|
|
4639
4653
|
}
|
|
4640
4654
|
|
|
4641
4655
|
// src/host/instructions-skills/io.ts
|
|
4642
|
-
import { existsSync as
|
|
4643
|
-
import { basename as
|
|
4656
|
+
import { existsSync as existsSync13, readFileSync as readFileSync6, statSync as statSync4 } from "node:fs";
|
|
4657
|
+
import { basename as basename13, join as join24, resolve as resolve15, sep as sep7 } from "node:path";
|
|
4644
4658
|
|
|
4645
4659
|
// src/host/instructions-skills/create.ts
|
|
4646
4660
|
import { existsSync as existsSync5, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
@@ -4791,8 +4805,8 @@ function createWorkspaceSkill(projectRoot, rawName) {
|
|
|
4791
4805
|
}
|
|
4792
4806
|
|
|
4793
4807
|
// src/host/instructions-skills/discover.ts
|
|
4794
|
-
import { existsSync as
|
|
4795
|
-
import { basename as
|
|
4808
|
+
import { existsSync as existsSync9, readdirSync as readdirSync3, readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
|
|
4809
|
+
import { basename as basename9, dirname as dirname7, join as join17, resolve as resolve11 } from "node:path";
|
|
4796
4810
|
|
|
4797
4811
|
// src/host/instructions-skills/types.ts
|
|
4798
4812
|
function defaultSkillInstallMeta() {
|
|
@@ -4804,15 +4818,78 @@ function defaultSkillInstallMeta() {
|
|
|
4804
4818
|
};
|
|
4805
4819
|
}
|
|
4806
4820
|
|
|
4821
|
+
// src/host/instructions-skills/transient-paths.ts
|
|
4822
|
+
import { existsSync as existsSync6, lstatSync, readdirSync, renameSync as renameSync2, rmSync, unlinkSync } from "node:fs";
|
|
4823
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
4824
|
+
import { basename as basename6, join as join13, resolve as resolve8 } from "node:path";
|
|
4825
|
+
var TRANSIENT_MARK = /\.__ae_(?:removing|installing)_/;
|
|
4826
|
+
function isTransientSkillEntryName(name2) {
|
|
4827
|
+
const base = basename6(name2.trim());
|
|
4828
|
+
if (base === "") return false;
|
|
4829
|
+
return TRANSIENT_MARK.test(base) || base.startsWith("ae-skill-removing-") || base.startsWith("ae-skill-installing-");
|
|
4830
|
+
}
|
|
4831
|
+
function skillTransientWorkPath(kind, skillName) {
|
|
4832
|
+
const safe = skillName.replace(/[^a-zA-Z0-9._-]+/g, "-").slice(0, 80) || "skill";
|
|
4833
|
+
return join13(tmpdir2(), `ae-skill-${kind}-${safe}-${process.pid}-${Date.now()}`);
|
|
4834
|
+
}
|
|
4835
|
+
function sweepTransientSkillEntries(skillsRoot) {
|
|
4836
|
+
const root = resolve8(skillsRoot);
|
|
4837
|
+
let names;
|
|
4838
|
+
try {
|
|
4839
|
+
names = readdirSync(root);
|
|
4840
|
+
} catch {
|
|
4841
|
+
return;
|
|
4842
|
+
}
|
|
4843
|
+
for (const name2 of names) {
|
|
4844
|
+
if (!isTransientSkillEntryName(name2)) continue;
|
|
4845
|
+
const full = join13(root, name2);
|
|
4846
|
+
try {
|
|
4847
|
+
rmSync(full, { recursive: true, force: true, maxRetries: 2, retryDelay: 20 });
|
|
4848
|
+
} catch {
|
|
4849
|
+
}
|
|
4850
|
+
}
|
|
4851
|
+
}
|
|
4852
|
+
function renameAsideToTemp(from, kind) {
|
|
4853
|
+
const absolute = resolve8(from);
|
|
4854
|
+
const preferred = skillTransientWorkPath(kind, basename6(absolute));
|
|
4855
|
+
try {
|
|
4856
|
+
renameSync2(absolute, preferred);
|
|
4857
|
+
return preferred;
|
|
4858
|
+
} catch {
|
|
4859
|
+
const sibling = `${absolute}.__ae_${kind}_${process.pid}_${Date.now()}`;
|
|
4860
|
+
renameSync2(absolute, sibling);
|
|
4861
|
+
return sibling;
|
|
4862
|
+
}
|
|
4863
|
+
}
|
|
4864
|
+
function removeQuietly(path) {
|
|
4865
|
+
try {
|
|
4866
|
+
const stat = lstatSync(path);
|
|
4867
|
+
if (stat.isSymbolicLink()) {
|
|
4868
|
+
try {
|
|
4869
|
+
unlinkSync(path);
|
|
4870
|
+
} catch {
|
|
4871
|
+
}
|
|
4872
|
+
return;
|
|
4873
|
+
}
|
|
4874
|
+
} catch {
|
|
4875
|
+
return;
|
|
4876
|
+
}
|
|
4877
|
+
if (!existsSync6(path)) return;
|
|
4878
|
+
try {
|
|
4879
|
+
rmSync(path, { recursive: true, force: true, maxRetries: 2, retryDelay: 20 });
|
|
4880
|
+
} catch {
|
|
4881
|
+
}
|
|
4882
|
+
}
|
|
4883
|
+
|
|
4807
4884
|
// src/host/instructions-skills/uninstall.ts
|
|
4808
|
-
import { lstatSync as
|
|
4809
|
-
import { basename as
|
|
4885
|
+
import { lstatSync as lstatSync3 } from "node:fs";
|
|
4886
|
+
import { basename as basename8, dirname as dirname6, join as join16, resolve as resolve10 } from "node:path";
|
|
4810
4887
|
|
|
4811
4888
|
// src/host/instructions-skills/install-ledger.ts
|
|
4812
|
-
import { existsSync as
|
|
4813
|
-
import { dirname as dirname5, join as
|
|
4889
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync2, renameSync as renameSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
4890
|
+
import { dirname as dirname5, join as join14 } from "node:path";
|
|
4814
4891
|
function ledgerPath(dataRoot) {
|
|
4815
|
-
return
|
|
4892
|
+
return join14(dataRoot, "skills-install", "registry.json");
|
|
4816
4893
|
}
|
|
4817
4894
|
function writeLedger(dataRoot, ledger) {
|
|
4818
4895
|
const path = ledgerPath(dataRoot);
|
|
@@ -4820,11 +4897,11 @@ function writeLedger(dataRoot, ledger) {
|
|
|
4820
4897
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
4821
4898
|
writeFileSync3(tmp, `${JSON.stringify(ledger, null, 2)}
|
|
4822
4899
|
`, "utf8");
|
|
4823
|
-
|
|
4900
|
+
renameSync3(tmp, path);
|
|
4824
4901
|
}
|
|
4825
4902
|
function readInstallLedger(dataRoot) {
|
|
4826
4903
|
const path = ledgerPath(dataRoot);
|
|
4827
|
-
if (!
|
|
4904
|
+
if (!existsSync7(path)) return {};
|
|
4828
4905
|
try {
|
|
4829
4906
|
const raw = readFileSync2(path, "utf8").trim();
|
|
4830
4907
|
if (raw === "") return {};
|
|
@@ -4845,33 +4922,100 @@ function removeInstallRecord(dataRoot, name2) {
|
|
|
4845
4922
|
}
|
|
4846
4923
|
|
|
4847
4924
|
// src/host/instructions-skills/remove-path.ts
|
|
4925
|
+
import { execFileSync } from "node:child_process";
|
|
4848
4926
|
import {
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4927
|
+
chmodSync,
|
|
4928
|
+
existsSync as existsSync8,
|
|
4929
|
+
lstatSync as lstatSync2,
|
|
4930
|
+
readdirSync as readdirSync2,
|
|
4931
|
+
readlinkSync,
|
|
4932
|
+
rmSync as rmSync2,
|
|
4933
|
+
unlinkSync as unlinkSync2
|
|
4855
4934
|
} from "node:fs";
|
|
4856
|
-
import {
|
|
4935
|
+
import { homedir as homedir3 } from "node:os";
|
|
4936
|
+
import { basename as basename7, join as join15, resolve as resolve9 } from "node:path";
|
|
4937
|
+
|
|
4938
|
+
// src/host/instructions-skills/fs-access.ts
|
|
4939
|
+
var ACCESS_DENIED_RE = /eperm|eacces|eio|ebusy|access is denied|operation not permitted|file in use|still present|拒绝访问|¾Ü¾ø·ÃÎÊ/i;
|
|
4940
|
+
function nodeErrno(error) {
|
|
4941
|
+
if (typeof error !== "object" || error === null) return null;
|
|
4942
|
+
const code = Reflect.get(error, "code");
|
|
4943
|
+
return typeof code === "string" ? code : null;
|
|
4944
|
+
}
|
|
4945
|
+
function isWindowsPathBusyError(error) {
|
|
4946
|
+
const code = nodeErrno(error);
|
|
4947
|
+
if (code === "EPERM" || code === "EACCES" || code === "EBUSY" || code === "EIO") return true;
|
|
4948
|
+
const text3 = error instanceof Error ? error.message : String(error ?? "");
|
|
4949
|
+
return ACCESS_DENIED_RE.test(text3);
|
|
4950
|
+
}
|
|
4951
|
+
function busyPathHint(pathLabel) {
|
|
4952
|
+
return `Failed to update ${pathLabel}: still present (EPERM / EIO / file in use \u2014 close skill preview or Desktop file tabs, then retry)`;
|
|
4953
|
+
}
|
|
4954
|
+
|
|
4955
|
+
// src/host/instructions-skills/remove-path.ts
|
|
4857
4956
|
function pathPresent(path) {
|
|
4858
4957
|
try {
|
|
4859
|
-
|
|
4958
|
+
lstatSync2(path);
|
|
4959
|
+
return true;
|
|
4960
|
+
} catch {
|
|
4961
|
+
return false;
|
|
4962
|
+
}
|
|
4963
|
+
}
|
|
4964
|
+
function isManagedSkillEntryPath(target, env = process.env) {
|
|
4965
|
+
const absolute = resolve9(target);
|
|
4966
|
+
const managedRoots = [
|
|
4967
|
+
join15(agentsHomeOf(env), "skills"),
|
|
4968
|
+
join15(dshHomeOf(env), "skills")
|
|
4969
|
+
];
|
|
4970
|
+
for (const root of managedRoots) {
|
|
4971
|
+
if (samePath2(absolute, root) || isInsideOrSame(root, absolute)) return true;
|
|
4972
|
+
}
|
|
4973
|
+
return false;
|
|
4974
|
+
}
|
|
4975
|
+
function isProtectedExternalSkillPath(target, env = process.env) {
|
|
4976
|
+
const absolute = resolve9(target);
|
|
4977
|
+
if (isManagedSkillEntryPath(absolute, env)) return false;
|
|
4978
|
+
const home = resolve9(homedir3());
|
|
4979
|
+
const protectedRoots = [
|
|
4980
|
+
join15(home, ".skills-manager"),
|
|
4981
|
+
join15(home, ".cursor", "skills"),
|
|
4982
|
+
join15(home, ".cursor", "skills-cursor"),
|
|
4983
|
+
join15(home, ".codex", "skills"),
|
|
4984
|
+
join15(home, ".claude", "skills"),
|
|
4985
|
+
join15(home, ".codebuddy", "skills"),
|
|
4986
|
+
join15(home, ".workbuddy", "skills")
|
|
4987
|
+
];
|
|
4988
|
+
for (const root of protectedRoots) {
|
|
4989
|
+
if (samePath2(absolute, root) || isInsideOrSame(root, absolute)) return true;
|
|
4990
|
+
}
|
|
4991
|
+
return false;
|
|
4992
|
+
}
|
|
4993
|
+
function isReparseOrSymlink(path) {
|
|
4994
|
+
try {
|
|
4995
|
+
const stat = lstatSync2(path);
|
|
4996
|
+
if (stat.isSymbolicLink()) return true;
|
|
4997
|
+
if (!stat.isDirectory() && !stat.isFile()) return true;
|
|
4998
|
+
} catch {
|
|
4999
|
+
return false;
|
|
5000
|
+
}
|
|
5001
|
+
if (process.platform !== "win32") return false;
|
|
5002
|
+
try {
|
|
5003
|
+
readlinkSync(path);
|
|
4860
5004
|
return true;
|
|
4861
5005
|
} catch {
|
|
4862
5006
|
return false;
|
|
4863
5007
|
}
|
|
4864
5008
|
}
|
|
4865
5009
|
function effectivelyGone(target) {
|
|
4866
|
-
if (!pathPresent(target) && !
|
|
5010
|
+
if (!pathPresent(target) && !existsSync8(target)) return true;
|
|
4867
5011
|
try {
|
|
4868
|
-
const stat =
|
|
5012
|
+
const stat = lstatSync2(target);
|
|
4869
5013
|
if (stat.isSymbolicLink()) return false;
|
|
4870
5014
|
if (!stat.isDirectory()) return false;
|
|
4871
|
-
if (
|
|
5015
|
+
if (existsSync8(join15(target, "SKILL.md"))) return false;
|
|
4872
5016
|
let names;
|
|
4873
5017
|
try {
|
|
4874
|
-
names =
|
|
5018
|
+
names = readdirSync2(target);
|
|
4875
5019
|
} catch {
|
|
4876
5020
|
return true;
|
|
4877
5021
|
}
|
|
@@ -4880,54 +5024,100 @@ function effectivelyGone(target) {
|
|
|
4880
5024
|
return true;
|
|
4881
5025
|
}
|
|
4882
5026
|
}
|
|
4883
|
-
function
|
|
4884
|
-
const absolute = resolve8(target);
|
|
4885
|
-
if (effectivelyGone(absolute)) return;
|
|
5027
|
+
function unlinkMountOnly(absolute) {
|
|
4886
5028
|
try {
|
|
4887
|
-
|
|
4888
|
-
|
|
5029
|
+
unlinkSync2(absolute);
|
|
5030
|
+
} catch {
|
|
5031
|
+
if (process.platform === "win32") {
|
|
4889
5032
|
try {
|
|
4890
|
-
|
|
5033
|
+
execFileSync("cmd", ["/d", "/s", "/c", `rmdir "${absolute.replace(/"/g, "")}"`], {
|
|
5034
|
+
windowsHide: true,
|
|
5035
|
+
timeout: 15e3,
|
|
5036
|
+
stdio: "ignore"
|
|
5037
|
+
});
|
|
4891
5038
|
} catch {
|
|
5039
|
+
return false;
|
|
4892
5040
|
}
|
|
4893
|
-
|
|
5041
|
+
} else {
|
|
5042
|
+
return false;
|
|
4894
5043
|
}
|
|
4895
|
-
} catch {
|
|
4896
|
-
if (effectivelyGone(absolute)) return;
|
|
4897
5044
|
}
|
|
5045
|
+
return !pathPresent(absolute) && !existsSync8(absolute);
|
|
5046
|
+
}
|
|
5047
|
+
function tryUnlinkReparseOrFile(absolute) {
|
|
5048
|
+
let preferUnlink = false;
|
|
4898
5049
|
try {
|
|
4899
|
-
|
|
5050
|
+
const stat = lstatSync2(absolute);
|
|
5051
|
+
if (stat.isSymbolicLink() || stat.isFile()) preferUnlink = true;
|
|
5052
|
+
else if (!stat.isDirectory()) preferUnlink = true;
|
|
5053
|
+
else if (isReparseOrSymlink(absolute)) preferUnlink = true;
|
|
4900
5054
|
} catch {
|
|
5055
|
+
if (effectivelyGone(absolute)) return true;
|
|
4901
5056
|
}
|
|
4902
|
-
if (
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
5057
|
+
if (!preferUnlink) return false;
|
|
5058
|
+
return unlinkMountOnly(absolute);
|
|
5059
|
+
}
|
|
5060
|
+
function removePathRobust(target) {
|
|
5061
|
+
const absolute = resolve9(target);
|
|
5062
|
+
if (isProtectedExternalSkillPath(absolute)) {
|
|
5063
|
+
return;
|
|
5064
|
+
}
|
|
5065
|
+
if (!pathPresent(absolute) && !existsSync8(absolute)) return;
|
|
5066
|
+
if (isReparseOrSymlink(absolute)) {
|
|
5067
|
+
if (unlinkMountOnly(absolute)) return;
|
|
5068
|
+
if (effectivelyGone(absolute)) return;
|
|
5069
|
+
throw new AuxiliaryError("FILE_EDIT_FAILED", busyPathHint(basename7(absolute)));
|
|
5070
|
+
}
|
|
5071
|
+
if (tryUnlinkReparseOrFile(absolute)) return;
|
|
5072
|
+
if (process.platform === "win32") {
|
|
4906
5073
|
try {
|
|
4907
|
-
|
|
5074
|
+
chmodSync(absolute, 438);
|
|
4908
5075
|
} catch {
|
|
4909
5076
|
}
|
|
5077
|
+
}
|
|
5078
|
+
try {
|
|
5079
|
+
rmSync2(absolute, { recursive: true, force: true, maxRetries: 3, retryDelay: 40 });
|
|
5080
|
+
} catch (error) {
|
|
5081
|
+
if (!isWindowsPathBusyError(error) && effectivelyGone(absolute)) return;
|
|
5082
|
+
}
|
|
5083
|
+
if (!pathPresent(absolute) && !existsSync8(absolute)) return;
|
|
5084
|
+
try {
|
|
5085
|
+
const aside = renameAsideToTemp(absolute, "removing");
|
|
5086
|
+
removeQuietly(aside);
|
|
4910
5087
|
return;
|
|
4911
5088
|
} catch {
|
|
4912
5089
|
}
|
|
4913
|
-
if (
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
5090
|
+
if (process.platform === "win32") {
|
|
5091
|
+
if (isReparseOrSymlink(absolute)) {
|
|
5092
|
+
if (unlinkMountOnly(absolute)) return;
|
|
5093
|
+
} else {
|
|
5094
|
+
try {
|
|
5095
|
+
execFileSync("cmd", ["/d", "/s", "/c", `rmdir /s /q "${absolute.replace(/"/g, "")}"`], {
|
|
5096
|
+
windowsHide: true,
|
|
5097
|
+
timeout: 3e4,
|
|
5098
|
+
stdio: "ignore"
|
|
5099
|
+
});
|
|
5100
|
+
} catch {
|
|
5101
|
+
}
|
|
5102
|
+
}
|
|
5103
|
+
if (!pathPresent(absolute) && !existsSync8(absolute)) return;
|
|
5104
|
+
if (effectivelyGone(absolute)) return;
|
|
5105
|
+
}
|
|
5106
|
+
if (effectivelyGone(absolute) || !pathPresent(absolute) && !existsSync8(absolute)) return;
|
|
5107
|
+
throw new AuxiliaryError("FILE_EDIT_FAILED", busyPathHint(basename7(absolute)));
|
|
4918
5108
|
}
|
|
4919
5109
|
|
|
4920
5110
|
// src/host/instructions-skills/uninstall.ts
|
|
4921
5111
|
function skillEntryPath(skillMdOrBundlePath) {
|
|
4922
|
-
const absolute =
|
|
4923
|
-
const base =
|
|
5112
|
+
const absolute = resolve10(skillMdOrBundlePath);
|
|
5113
|
+
const base = basename8(absolute);
|
|
4924
5114
|
if (base.toLowerCase() === "skill.md") return dirname6(absolute);
|
|
4925
5115
|
if (base.toLowerCase().endsWith(".md")) return absolute;
|
|
4926
5116
|
return absolute;
|
|
4927
5117
|
}
|
|
4928
5118
|
function pathPresent2(path) {
|
|
4929
5119
|
try {
|
|
4930
|
-
|
|
5120
|
+
lstatSync3(path);
|
|
4931
5121
|
return true;
|
|
4932
5122
|
} catch {
|
|
4933
5123
|
return false;
|
|
@@ -4936,8 +5126,8 @@ function pathPresent2(path) {
|
|
|
4936
5126
|
function managedSkillEntriesForName(root, name2) {
|
|
4937
5127
|
if (!isKebabCaseName(name2)) return [];
|
|
4938
5128
|
const out = [];
|
|
4939
|
-
const asDir =
|
|
4940
|
-
const asFile =
|
|
5129
|
+
const asDir = join16(root, name2);
|
|
5130
|
+
const asFile = join16(root, `${name2}.md`);
|
|
4941
5131
|
for (const entry of [asDir, asFile]) {
|
|
4942
5132
|
if (!pathPresent2(entry)) continue;
|
|
4943
5133
|
if (!samePath2(dirname6(entry), root)) continue;
|
|
@@ -4950,8 +5140,8 @@ function resolveManagedSkillRemovalTarget(path, name2, managedRoots) {
|
|
|
4950
5140
|
if (!isKebabCaseName(name2)) return null;
|
|
4951
5141
|
const entry = skillEntryPath(path);
|
|
4952
5142
|
for (const root of managedRoots) {
|
|
4953
|
-
const asDir =
|
|
4954
|
-
const asFile =
|
|
5143
|
+
const asDir = join16(root, name2);
|
|
5144
|
+
const asFile = join16(root, `${name2}.md`);
|
|
4955
5145
|
if (samePath2(entry, asDir) || samePath2(entry, asFile)) {
|
|
4956
5146
|
if (!pathPresent2(entry)) return null;
|
|
4957
5147
|
if (!samePath2(dirname6(entry), root)) return null;
|
|
@@ -4971,18 +5161,20 @@ function purgeManagedSkillName(options) {
|
|
|
4971
5161
|
if (!isKebabCaseName(name2)) {
|
|
4972
5162
|
throw new AuxiliaryError("FILE_DENIED", `Invalid skill name: ${name2}`);
|
|
4973
5163
|
}
|
|
5164
|
+
const except = (options.exceptPaths ?? []).map((entry) => resolve10(entry));
|
|
4974
5165
|
const roots = skillRootsFor(options.cwd, options.projectRoot, options.env);
|
|
4975
5166
|
const purgeTargets = /* @__PURE__ */ new Set();
|
|
4976
5167
|
for (const extra of options.also ?? []) {
|
|
4977
|
-
purgeTargets.add(
|
|
5168
|
+
purgeTargets.add(resolve10(extra));
|
|
4978
5169
|
}
|
|
4979
5170
|
for (const root of roots) {
|
|
4980
5171
|
for (const entry of managedSkillEntriesForName(root, name2)) {
|
|
4981
|
-
purgeTargets.add(
|
|
5172
|
+
purgeTargets.add(resolve10(entry));
|
|
4982
5173
|
}
|
|
4983
5174
|
}
|
|
4984
5175
|
const removed = [];
|
|
4985
5176
|
for (const entry of purgeTargets) {
|
|
5177
|
+
if (except.some((skip) => samePath2(skip, entry))) continue;
|
|
4986
5178
|
removePathRobust(entry);
|
|
4987
5179
|
removed.push(entry);
|
|
4988
5180
|
}
|
|
@@ -5017,54 +5209,54 @@ function uninstallManagedSkill(options) {
|
|
|
5017
5209
|
|
|
5018
5210
|
// src/host/instructions-skills/discover.ts
|
|
5019
5211
|
function entryId(scope, path) {
|
|
5020
|
-
return `${scope}:${
|
|
5212
|
+
return `${scope}:${resolve11(path).toLowerCase()}`;
|
|
5021
5213
|
}
|
|
5022
5214
|
function pushUnique(out, seen, entry) {
|
|
5023
|
-
const key =
|
|
5215
|
+
const key = resolve11(entry.path).toLowerCase();
|
|
5024
5216
|
if (seen.has(key)) return;
|
|
5025
5217
|
seen.add(key);
|
|
5026
5218
|
out.push(entry);
|
|
5027
5219
|
}
|
|
5028
5220
|
function discoverInstructionFiles(options) {
|
|
5029
5221
|
const env = options.env ?? process.env;
|
|
5030
|
-
const cwd =
|
|
5222
|
+
const cwd = resolve11(options.cwd);
|
|
5031
5223
|
const projectRoot = findProjectRoot(cwd);
|
|
5032
5224
|
const seen = /* @__PURE__ */ new Set();
|
|
5033
5225
|
const instructions = [];
|
|
5034
|
-
const globalPath =
|
|
5226
|
+
const globalPath = join17(dshHomeOf(env), "AGENTS.md");
|
|
5035
5227
|
pushUnique(instructions, seen, {
|
|
5036
5228
|
id: entryId("global", globalPath),
|
|
5037
5229
|
scope: "global",
|
|
5038
5230
|
name: "AGENTS.md",
|
|
5039
5231
|
path: globalPath,
|
|
5040
|
-
exists:
|
|
5232
|
+
exists: existsSync9(globalPath),
|
|
5041
5233
|
bytes: fileBytes(globalPath),
|
|
5042
5234
|
createable: false
|
|
5043
5235
|
});
|
|
5044
|
-
const sharedPath =
|
|
5236
|
+
const sharedPath = join17(agentsHomeOf(env), "AGENTS.md");
|
|
5045
5237
|
pushUnique(instructions, seen, {
|
|
5046
5238
|
id: entryId("shared", sharedPath),
|
|
5047
5239
|
scope: "shared",
|
|
5048
5240
|
name: "AGENTS.md",
|
|
5049
5241
|
path: sharedPath,
|
|
5050
|
-
exists:
|
|
5242
|
+
exists: existsSync9(sharedPath),
|
|
5051
5243
|
bytes: fileBytes(sharedPath),
|
|
5052
5244
|
createable: false
|
|
5053
5245
|
});
|
|
5054
|
-
const rootAgents =
|
|
5246
|
+
const rootAgents = join17(projectRoot, "AGENTS.md");
|
|
5055
5247
|
pushUnique(instructions, seen, {
|
|
5056
5248
|
id: entryId("project", rootAgents),
|
|
5057
5249
|
scope: "project",
|
|
5058
5250
|
name: "AGENTS.md",
|
|
5059
5251
|
path: rootAgents,
|
|
5060
|
-
exists:
|
|
5252
|
+
exists: existsSync9(rootAgents),
|
|
5061
5253
|
bytes: fileBytes(rootAgents),
|
|
5062
|
-
createable: !
|
|
5254
|
+
createable: !existsSync9(rootAgents)
|
|
5063
5255
|
});
|
|
5064
5256
|
for (const dir of projectChainDirs(projectRoot, cwd)) {
|
|
5065
5257
|
for (const name2 of INSTRUCTION_CANDIDATES) {
|
|
5066
|
-
const path =
|
|
5067
|
-
if (!
|
|
5258
|
+
const path = join17(dir, name2);
|
|
5259
|
+
if (!existsSync9(path)) continue;
|
|
5068
5260
|
if (samePath2(path, rootAgents)) continue;
|
|
5069
5261
|
pushUnique(instructions, seen, {
|
|
5070
5262
|
id: entryId("project", path),
|
|
@@ -5099,21 +5291,23 @@ function discoverFilesystemSkills(options) {
|
|
|
5099
5291
|
const byName = /* @__PURE__ */ new Map();
|
|
5100
5292
|
for (const root of roots) {
|
|
5101
5293
|
const managedRoot = managed.some((path) => samePath2(path, root));
|
|
5294
|
+
if (managedRoot) sweepTransientSkillEntries(root);
|
|
5102
5295
|
let names;
|
|
5103
5296
|
try {
|
|
5104
|
-
names =
|
|
5297
|
+
names = readdirSync3(root);
|
|
5105
5298
|
} catch {
|
|
5106
5299
|
continue;
|
|
5107
5300
|
}
|
|
5108
5301
|
for (const name2 of names) {
|
|
5109
|
-
|
|
5110
|
-
|
|
5302
|
+
if (isTransientSkillEntryName(name2)) continue;
|
|
5303
|
+
const skillMd = join17(root, name2, "SKILL.md");
|
|
5304
|
+
if (!existsSync9(skillMd)) continue;
|
|
5111
5305
|
if (byName.has(name2)) continue;
|
|
5112
5306
|
byName.set(name2, {
|
|
5113
|
-
id: `fs:${
|
|
5307
|
+
id: `fs:${resolve11(skillMd).toLowerCase()}`,
|
|
5114
5308
|
name: name2,
|
|
5115
5309
|
description: descriptionFromSkillMd(skillMd),
|
|
5116
|
-
path:
|
|
5310
|
+
path: resolve11(skillMd),
|
|
5117
5311
|
provider: dirnameLabel(root, options.projectRoot, env),
|
|
5118
5312
|
modelInvocable: null,
|
|
5119
5313
|
userInvocable: null,
|
|
@@ -5126,12 +5320,12 @@ function discoverFilesystemSkills(options) {
|
|
|
5126
5320
|
return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
5127
5321
|
}
|
|
5128
5322
|
function dirnameLabel(root, projectRoot, env) {
|
|
5129
|
-
if (samePath2(root,
|
|
5130
|
-
if (samePath2(root,
|
|
5131
|
-
if (samePath2(root,
|
|
5132
|
-
if (samePath2(root,
|
|
5133
|
-
const parent =
|
|
5134
|
-
const leaf =
|
|
5323
|
+
if (samePath2(root, join17(projectRoot, ".agents", "skills"))) return "project";
|
|
5324
|
+
if (samePath2(root, join17(projectRoot, ".dsh", "skills"))) return "project-dsh";
|
|
5325
|
+
if (samePath2(root, join17(agentsHomeOf(env), "skills"))) return "shared";
|
|
5326
|
+
if (samePath2(root, join17(dshHomeOf(env), "skills"))) return "dsh-home";
|
|
5327
|
+
const parent = basename9(dirname7(root)).toLowerCase();
|
|
5328
|
+
const leaf = basename9(root).toLowerCase();
|
|
5135
5329
|
if (parent === ".cursor" && leaf === "skills") return "cursor";
|
|
5136
5330
|
if (parent === ".cursor" && leaf === "skills-cursor") return "cursor-builtin";
|
|
5137
5331
|
if (parent === ".codex") return "codex";
|
|
@@ -5149,7 +5343,7 @@ function normalizeRegistrySkills(raw) {
|
|
|
5149
5343
|
const name2 = typeof row.name === "string" ? row.name.trim() : "";
|
|
5150
5344
|
if (name2 === "" || seen.has(name2)) continue;
|
|
5151
5345
|
seen.add(name2);
|
|
5152
|
-
const path = typeof row.path === "string" && row.path.trim() !== "" ?
|
|
5346
|
+
const path = typeof row.path === "string" && row.path.trim() !== "" ? resolve11(row.path.trim()) : null;
|
|
5153
5347
|
out.push({
|
|
5154
5348
|
id: path !== null ? `reg:${path.toLowerCase()}` : `reg:${name2}`,
|
|
5155
5349
|
name: name2,
|
|
@@ -5166,24 +5360,24 @@ function normalizeRegistrySkills(raw) {
|
|
|
5166
5360
|
}
|
|
5167
5361
|
function coerceSkillDocumentPath(path, _name) {
|
|
5168
5362
|
if (path === null || path.trim() === "") return null;
|
|
5169
|
-
const absolute =
|
|
5170
|
-
if (
|
|
5363
|
+
const absolute = resolve11(path.trim());
|
|
5364
|
+
if (existsSync9(absolute)) {
|
|
5171
5365
|
try {
|
|
5172
5366
|
if (statSync2(absolute).isFile()) return absolute;
|
|
5173
5367
|
} catch {
|
|
5174
5368
|
}
|
|
5175
|
-
const asFile =
|
|
5176
|
-
if (
|
|
5369
|
+
const asFile = join17(absolute, "SKILL.md");
|
|
5370
|
+
if (existsSync9(asFile)) return asFile;
|
|
5177
5371
|
}
|
|
5178
5372
|
const lower = absolute.toLowerCase();
|
|
5179
5373
|
if (lower.endsWith("skill.md") || lower.endsWith(".md")) return absolute;
|
|
5180
|
-
const nested =
|
|
5181
|
-
return
|
|
5374
|
+
const nested = join17(absolute, "SKILL.md");
|
|
5375
|
+
return existsSync9(nested) ? nested : absolute;
|
|
5182
5376
|
}
|
|
5183
5377
|
function resolveSkillPathFromRoots(name2, cwd, projectRoot, env) {
|
|
5184
5378
|
for (const root of previewSkillSearchRoots(cwd, projectRoot, env)) {
|
|
5185
|
-
const skillMd =
|
|
5186
|
-
if (
|
|
5379
|
+
const skillMd = join17(root, name2, "SKILL.md");
|
|
5380
|
+
if (existsSync9(skillMd)) return resolve11(skillMd);
|
|
5187
5381
|
}
|
|
5188
5382
|
return null;
|
|
5189
5383
|
}
|
|
@@ -5343,10 +5537,10 @@ function parseGitSkillSource(raw) {
|
|
|
5343
5537
|
}
|
|
5344
5538
|
|
|
5345
5539
|
// src/host/instructions-skills/install.ts
|
|
5346
|
-
import { execFile as execFile3 } from "node:child_process";
|
|
5347
|
-
import { existsSync as
|
|
5348
|
-
import { tmpdir as
|
|
5349
|
-
import { basename as
|
|
5540
|
+
import { execFile as execFile3, spawn } from "node:child_process";
|
|
5541
|
+
import { existsSync as existsSync11, mkdtempSync, realpathSync, rmSync as rmSync4 } from "node:fs";
|
|
5542
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
5543
|
+
import { basename as basename11, dirname as dirname9, join as join21, resolve as resolve13 } from "node:path";
|
|
5350
5544
|
import { promisify as promisify3 } from "node:util";
|
|
5351
5545
|
|
|
5352
5546
|
// src/host/instructions-skills/github-archive.ts
|
|
@@ -5354,12 +5548,12 @@ import { execFile as execFile2 } from "node:child_process";
|
|
|
5354
5548
|
import {
|
|
5355
5549
|
createWriteStream,
|
|
5356
5550
|
mkdirSync as mkdirSync4,
|
|
5357
|
-
readdirSync as
|
|
5551
|
+
readdirSync as readdirSync4,
|
|
5358
5552
|
renameSync as renameSync4,
|
|
5359
|
-
rmSync as
|
|
5553
|
+
rmSync as rmSync3,
|
|
5360
5554
|
statSync as statSync3
|
|
5361
5555
|
} from "node:fs";
|
|
5362
|
-
import { join as
|
|
5556
|
+
import { join as join18 } from "node:path";
|
|
5363
5557
|
import { Readable } from "node:stream";
|
|
5364
5558
|
import { pipeline } from "node:stream/promises";
|
|
5365
5559
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -5371,7 +5565,7 @@ function detailOf(error) {
|
|
|
5371
5565
|
const body = [error.message, stderr.trim()].filter((part) => part !== "").join("\n");
|
|
5372
5566
|
return body.slice(0, 800);
|
|
5373
5567
|
}
|
|
5374
|
-
async function downloadUrl(url, destFile, signal) {
|
|
5568
|
+
async function downloadUrl(url, destFile, signal, onBytes) {
|
|
5375
5569
|
signal.throwIfAborted();
|
|
5376
5570
|
const response = await fetch(url, {
|
|
5377
5571
|
signal,
|
|
@@ -5387,11 +5581,20 @@ async function downloadUrl(url, destFile, signal) {
|
|
|
5387
5581
|
if (response.body === null) {
|
|
5388
5582
|
throw new Error(`Empty body from ${url}`);
|
|
5389
5583
|
}
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5584
|
+
const lengthHeader = response.headers.get("content-length");
|
|
5585
|
+
const parsedTotal = lengthHeader !== null ? Number(lengthHeader) : Number.NaN;
|
|
5586
|
+
const bytesTotal = Number.isFinite(parsedTotal) && parsedTotal > 0 ? parsedTotal : null;
|
|
5587
|
+
let bytesReceived = 0;
|
|
5588
|
+
onBytes?.(0, bytesTotal);
|
|
5589
|
+
const source = Readable.fromWeb(response.body);
|
|
5590
|
+
source.on("data", (chunk) => {
|
|
5591
|
+
const size = typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.byteLength;
|
|
5592
|
+
bytesReceived += size;
|
|
5593
|
+
onBytes?.(bytesReceived, bytesTotal);
|
|
5594
|
+
});
|
|
5595
|
+
await pipeline(source, createWriteStream(destFile));
|
|
5394
5596
|
signal.throwIfAborted();
|
|
5597
|
+
onBytes?.(bytesReceived, bytesTotal);
|
|
5395
5598
|
}
|
|
5396
5599
|
async function extractZip(zipPath, destDir, signal) {
|
|
5397
5600
|
signal.throwIfAborted();
|
|
@@ -5409,12 +5612,12 @@ async function extractZip(zipPath, destDir, signal) {
|
|
|
5409
5612
|
function unwrapArchiveRoot(extractDir) {
|
|
5410
5613
|
let entries;
|
|
5411
5614
|
try {
|
|
5412
|
-
entries =
|
|
5615
|
+
entries = readdirSync4(extractDir).filter((name2) => name2 !== "__MACOSX");
|
|
5413
5616
|
} catch {
|
|
5414
5617
|
return extractDir;
|
|
5415
5618
|
}
|
|
5416
5619
|
if (entries.length !== 1) return extractDir;
|
|
5417
|
-
const only =
|
|
5620
|
+
const only = join18(extractDir, entries[0]);
|
|
5418
5621
|
try {
|
|
5419
5622
|
if (statSync3(only).isDirectory()) return only;
|
|
5420
5623
|
} catch {
|
|
@@ -5422,33 +5625,69 @@ function unwrapArchiveRoot(extractDir) {
|
|
|
5422
5625
|
}
|
|
5423
5626
|
return only;
|
|
5424
5627
|
}
|
|
5425
|
-
async function
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5628
|
+
async function resolveDefaultBranch(owner, repo, signal) {
|
|
5629
|
+
signal.throwIfAborted();
|
|
5630
|
+
try {
|
|
5631
|
+
const response = await fetch(`https://api.github.com/repos/${owner}/${repo}`, {
|
|
5632
|
+
signal,
|
|
5633
|
+
headers: {
|
|
5634
|
+
Accept: "application/vnd.github+json",
|
|
5635
|
+
"User-Agent": "dsh-agent-enhancer-skill-install"
|
|
5636
|
+
}
|
|
5637
|
+
});
|
|
5638
|
+
if (!response.ok) return null;
|
|
5639
|
+
const body = await response.json();
|
|
5640
|
+
return typeof body.default_branch === "string" && body.default_branch.trim() !== "" ? body.default_branch.trim() : null;
|
|
5641
|
+
} catch {
|
|
5642
|
+
return null;
|
|
5643
|
+
}
|
|
5644
|
+
}
|
|
5645
|
+
function archiveCandidates(owner, repo, defaultBranch) {
|
|
5646
|
+
const urls = [];
|
|
5647
|
+
if (defaultBranch !== null) {
|
|
5648
|
+
urls.push(`https://codeload.github.com/${owner}/${repo}/zip/refs/heads/${encodeURIComponent(defaultBranch)}`);
|
|
5649
|
+
}
|
|
5650
|
+
urls.push(
|
|
5432
5651
|
`https://api.github.com/repos/${owner}/${repo}/zipball`,
|
|
5433
5652
|
`https://codeload.github.com/${owner}/${repo}/zip/refs/heads/main`,
|
|
5434
5653
|
`https://codeload.github.com/${owner}/${repo}/zip/refs/heads/master`
|
|
5435
|
-
|
|
5654
|
+
);
|
|
5655
|
+
return [...new Set(urls)];
|
|
5656
|
+
}
|
|
5657
|
+
async function fetchGithubRepoArchive(options) {
|
|
5658
|
+
const { owner, repo, workDir, signal, onDownloadProgress, onStage } = options;
|
|
5659
|
+
mkdirSync4(workDir, { recursive: true });
|
|
5660
|
+
const zipPath = join18(workDir, "repo.zip");
|
|
5661
|
+
const extractDir = join18(workDir, "extract");
|
|
5662
|
+
mkdirSync4(extractDir, { recursive: true });
|
|
5663
|
+
const defaultBranch = await resolveDefaultBranch(owner, repo, signal);
|
|
5664
|
+
const candidates = archiveCandidates(owner, repo, defaultBranch);
|
|
5436
5665
|
const errors = [];
|
|
5437
|
-
|
|
5666
|
+
let downloadStarted = false;
|
|
5667
|
+
for (let index = 0; index < candidates.length; index += 1) {
|
|
5668
|
+
const url = candidates[index];
|
|
5438
5669
|
signal.throwIfAborted();
|
|
5439
5670
|
try {
|
|
5440
|
-
|
|
5441
|
-
|
|
5671
|
+
rmSync3(zipPath, { force: true });
|
|
5672
|
+
rmSync3(extractDir, { recursive: true, force: true });
|
|
5442
5673
|
mkdirSync4(extractDir, { recursive: true });
|
|
5443
|
-
|
|
5674
|
+
const detail = index === 0 ? `${owner}/${repo}` : `${owner}/${repo} \xB7 retry ${index + 1}/${candidates.length}`;
|
|
5675
|
+
if (!downloadStarted) {
|
|
5676
|
+
onStage?.("downloading", detail);
|
|
5677
|
+
downloadStarted = true;
|
|
5678
|
+
} else {
|
|
5679
|
+
onStage?.("downloading", detail);
|
|
5680
|
+
}
|
|
5681
|
+
await downloadUrl(url, zipPath, signal, onDownloadProgress);
|
|
5682
|
+
onStage?.("extracting", `${owner}/${repo}`);
|
|
5444
5683
|
await extractZip(zipPath, extractDir, signal);
|
|
5445
5684
|
const root = unwrapArchiveRoot(extractDir);
|
|
5446
|
-
const repoDir =
|
|
5447
|
-
|
|
5685
|
+
const repoDir = join18(workDir, "repo");
|
|
5686
|
+
rmSync3(repoDir, { recursive: true, force: true });
|
|
5448
5687
|
renameSync4(root, repoDir);
|
|
5449
5688
|
try {
|
|
5450
|
-
|
|
5451
|
-
|
|
5689
|
+
rmSync3(zipPath, { force: true });
|
|
5690
|
+
rmSync3(extractDir, { recursive: true, force: true });
|
|
5452
5691
|
} catch {
|
|
5453
5692
|
}
|
|
5454
5693
|
return repoDir;
|
|
@@ -5473,14 +5712,15 @@ async function fetchGithubRepoArchive(options) {
|
|
|
5473
5712
|
// src/host/instructions-skills/install-fs.ts
|
|
5474
5713
|
import {
|
|
5475
5714
|
cpSync,
|
|
5476
|
-
existsSync as
|
|
5477
|
-
lstatSync as
|
|
5715
|
+
existsSync as existsSync10,
|
|
5716
|
+
lstatSync as lstatSync4,
|
|
5478
5717
|
mkdirSync as mkdirSync5,
|
|
5479
|
-
readdirSync as
|
|
5718
|
+
readdirSync as readdirSync5,
|
|
5480
5719
|
readFileSync as readFileSync4,
|
|
5720
|
+
renameSync as renameSync5,
|
|
5481
5721
|
symlinkSync
|
|
5482
5722
|
} from "node:fs";
|
|
5483
|
-
import { basename as
|
|
5723
|
+
import { basename as basename10, dirname as dirname8, join as join19, resolve as resolve12 } from "node:path";
|
|
5484
5724
|
function frontmatterBlock(path) {
|
|
5485
5725
|
try {
|
|
5486
5726
|
const text3 = readFileSync4(path, "utf8");
|
|
@@ -5500,14 +5740,14 @@ function nameFromSkillPath(path, fallback) {
|
|
|
5500
5740
|
return fallback;
|
|
5501
5741
|
}
|
|
5502
5742
|
function directoryBundleName(dir, folderName) {
|
|
5503
|
-
return nameFromSkillPath(
|
|
5743
|
+
return nameFromSkillPath(join19(dir, "SKILL.md"), folderName);
|
|
5504
5744
|
}
|
|
5505
5745
|
function findSkillBundles(root) {
|
|
5506
|
-
const absolute =
|
|
5507
|
-
if (!
|
|
5508
|
-
const rootSkill =
|
|
5509
|
-
if (
|
|
5510
|
-
const folderName =
|
|
5746
|
+
const absolute = resolve12(root);
|
|
5747
|
+
if (!existsSync10(absolute)) return [];
|
|
5748
|
+
const rootSkill = join19(absolute, "SKILL.md");
|
|
5749
|
+
if (existsSync10(rootSkill)) {
|
|
5750
|
+
const folderName = basename10(absolute);
|
|
5511
5751
|
const name2 = directoryBundleName(absolute, folderName);
|
|
5512
5752
|
if (isKebabCaseName(name2)) {
|
|
5513
5753
|
return [{ name: name2, sourcePath: absolute, kind: "directory" }];
|
|
@@ -5516,13 +5756,14 @@ function findSkillBundles(root) {
|
|
|
5516
5756
|
const out = [];
|
|
5517
5757
|
let entries;
|
|
5518
5758
|
try {
|
|
5519
|
-
entries =
|
|
5759
|
+
entries = readdirSync5(absolute);
|
|
5520
5760
|
} catch {
|
|
5521
5761
|
return [];
|
|
5522
5762
|
}
|
|
5523
5763
|
for (const entry of entries) {
|
|
5524
|
-
|
|
5525
|
-
|
|
5764
|
+
if (isTransientSkillEntryName(entry)) continue;
|
|
5765
|
+
const full = join19(absolute, entry);
|
|
5766
|
+
if (existsSync10(join19(full, "SKILL.md"))) {
|
|
5526
5767
|
const name2 = directoryBundleName(full, entry);
|
|
5527
5768
|
if (!isKebabCaseName(name2)) continue;
|
|
5528
5769
|
out.push({ name: name2, sourcePath: full, kind: "directory" });
|
|
@@ -5530,7 +5771,7 @@ function findSkillBundles(root) {
|
|
|
5530
5771
|
}
|
|
5531
5772
|
let isFile = false;
|
|
5532
5773
|
try {
|
|
5533
|
-
isFile =
|
|
5774
|
+
isFile = lstatSync4(full).isFile();
|
|
5534
5775
|
} catch {
|
|
5535
5776
|
continue;
|
|
5536
5777
|
}
|
|
@@ -5543,13 +5784,13 @@ function findSkillBundles(root) {
|
|
|
5543
5784
|
return out.sort((a, b) => a.name.localeCompare(b.name));
|
|
5544
5785
|
}
|
|
5545
5786
|
function resolveBundlesFromClone(cloneRoot, subpath) {
|
|
5546
|
-
const base = subpath === null || subpath === "" ?
|
|
5547
|
-
if (!
|
|
5787
|
+
const base = subpath === null || subpath === "" ? resolve12(cloneRoot) : resolve12(cloneRoot, subpath);
|
|
5788
|
+
if (!existsSync10(base)) {
|
|
5548
5789
|
throw new AuxiliaryError("FILE_NOT_FOUND", `Path not found in repository: ${subpath ?? "."}`);
|
|
5549
5790
|
}
|
|
5550
|
-
if (base.toLowerCase().endsWith("skill.md") &&
|
|
5791
|
+
if (base.toLowerCase().endsWith("skill.md") && existsSync10(base)) {
|
|
5551
5792
|
const dir = dirname8(base);
|
|
5552
|
-
const name2 = directoryBundleName(dir,
|
|
5793
|
+
const name2 = directoryBundleName(dir, basename10(dir));
|
|
5553
5794
|
if (!isKebabCaseName(name2)) {
|
|
5554
5795
|
throw new AuxiliaryError("FILE_DENIED", `Skill directory name must be kebab-case: ${name2}`);
|
|
5555
5796
|
}
|
|
@@ -5557,25 +5798,38 @@ function resolveBundlesFromClone(cloneRoot, subpath) {
|
|
|
5557
5798
|
}
|
|
5558
5799
|
const direct = findSkillBundles(base);
|
|
5559
5800
|
if (direct.length > 0) return direct;
|
|
5560
|
-
for (const rel of ["skills",
|
|
5561
|
-
const nested =
|
|
5801
|
+
for (const rel of ["skills", join19(".agents", "skills"), join19(".dsh", "skills")]) {
|
|
5802
|
+
const nested = join19(base, rel);
|
|
5562
5803
|
const found = findSkillBundles(nested);
|
|
5563
5804
|
if (found.length > 0) return found;
|
|
5564
5805
|
}
|
|
5565
5806
|
throw new AuxiliaryError("FILE_NOT_FOUND", "No SKILL.md bundles found in the repository path");
|
|
5566
5807
|
}
|
|
5567
|
-
function installTargetDir(target, projectRoot, agentsHome) {
|
|
5568
|
-
|
|
5808
|
+
function installTargetDir(target, projectRoot, agentsHome, dshHome2) {
|
|
5809
|
+
switch (target) {
|
|
5810
|
+
case "user":
|
|
5811
|
+
return join19(resolve12(agentsHome), "skills");
|
|
5812
|
+
case "user-dsh":
|
|
5813
|
+
return join19(resolve12(dshHome2), "skills");
|
|
5814
|
+
case "project":
|
|
5815
|
+
return join19(resolve12(projectRoot), ".agents", "skills");
|
|
5816
|
+
case "project-dsh":
|
|
5817
|
+
return join19(resolve12(projectRoot), ".dsh", "skills");
|
|
5818
|
+
default: {
|
|
5819
|
+
const _exhaustive = target;
|
|
5820
|
+
return _exhaustive;
|
|
5821
|
+
}
|
|
5822
|
+
}
|
|
5569
5823
|
}
|
|
5570
5824
|
function destinationForBundle(targetDir, bundle) {
|
|
5571
|
-
return bundle.kind === "directory" ?
|
|
5825
|
+
return bundle.kind === "directory" ? join19(targetDir, bundle.name) : join19(targetDir, `${bundle.name}.md`);
|
|
5572
5826
|
}
|
|
5573
5827
|
function removeDestination(dest) {
|
|
5574
5828
|
removePathRobust(dest);
|
|
5575
5829
|
}
|
|
5576
5830
|
function destinationPresent(path) {
|
|
5577
5831
|
try {
|
|
5578
|
-
|
|
5832
|
+
lstatSync4(path);
|
|
5579
5833
|
return true;
|
|
5580
5834
|
} catch {
|
|
5581
5835
|
return false;
|
|
@@ -5585,25 +5839,67 @@ function isStaleSkillDestination(dest, kind) {
|
|
|
5585
5839
|
if (!destinationPresent(dest)) return false;
|
|
5586
5840
|
if (kind === "file") {
|
|
5587
5841
|
try {
|
|
5588
|
-
const stat =
|
|
5589
|
-
if (stat.isSymbolicLink()) return !
|
|
5842
|
+
const stat = lstatSync4(dest);
|
|
5843
|
+
if (stat.isSymbolicLink()) return !existsSync10(dest);
|
|
5590
5844
|
return !stat.isFile();
|
|
5591
5845
|
} catch {
|
|
5592
5846
|
return true;
|
|
5593
5847
|
}
|
|
5594
5848
|
}
|
|
5595
|
-
return !
|
|
5849
|
+
return !existsSync10(join19(dest, "SKILL.md"));
|
|
5850
|
+
}
|
|
5851
|
+
function copySkillTree(source, dest) {
|
|
5852
|
+
try {
|
|
5853
|
+
cpSync(source, dest, { recursive: true });
|
|
5854
|
+
} catch (error) {
|
|
5855
|
+
if (isWindowsPathBusyError(error)) {
|
|
5856
|
+
throw new AuxiliaryError("FILE_EDIT_FAILED", busyPathHint(basename10(dest)));
|
|
5857
|
+
}
|
|
5858
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
5859
|
+
throw new AuxiliaryError(
|
|
5860
|
+
"FILE_EDIT_FAILED",
|
|
5861
|
+
`Failed to copy skill into ${basename10(dest)}: ${detail.slice(0, 400)}`
|
|
5862
|
+
);
|
|
5863
|
+
}
|
|
5596
5864
|
}
|
|
5597
|
-
function
|
|
5865
|
+
function copySkillTreeAtomic(source, dest, kind) {
|
|
5866
|
+
mkdirSync5(dirname8(dest), { recursive: true });
|
|
5867
|
+
if (kind === "file") {
|
|
5868
|
+
if (destinationPresent(dest)) removeDestination(dest);
|
|
5869
|
+
copySkillTree(source, dest);
|
|
5870
|
+
return;
|
|
5871
|
+
}
|
|
5872
|
+
const staging = skillTransientWorkPath("installing", basename10(dest));
|
|
5873
|
+
try {
|
|
5874
|
+
copySkillTree(source, staging);
|
|
5875
|
+
if (destinationPresent(dest)) removeDestination(dest);
|
|
5876
|
+
if (destinationPresent(dest)) {
|
|
5877
|
+
throw new AuxiliaryError("FILE_EDIT_FAILED", busyPathHint(basename10(dest)));
|
|
5878
|
+
}
|
|
5879
|
+
try {
|
|
5880
|
+
renameSync5(staging, dest);
|
|
5881
|
+
} catch (error) {
|
|
5882
|
+
if (isWindowsPathBusyError(error)) {
|
|
5883
|
+
throw new AuxiliaryError("FILE_EDIT_FAILED", busyPathHint(basename10(dest)));
|
|
5884
|
+
}
|
|
5885
|
+
copySkillTree(staging, dest);
|
|
5886
|
+
removeQuietly(staging);
|
|
5887
|
+
}
|
|
5888
|
+
} catch (error) {
|
|
5889
|
+
removeQuietly(staging);
|
|
5890
|
+
throw error;
|
|
5891
|
+
}
|
|
5892
|
+
}
|
|
5893
|
+
function linkOrCopy(source, dest, mode, kind) {
|
|
5598
5894
|
mkdirSync5(dirname8(dest), { recursive: true });
|
|
5599
5895
|
if (mode === "copy") {
|
|
5600
|
-
|
|
5896
|
+
copySkillTreeAtomic(source, dest, kind);
|
|
5601
5897
|
return "copy";
|
|
5602
5898
|
}
|
|
5603
5899
|
try {
|
|
5604
5900
|
if (process.platform === "win32") {
|
|
5605
|
-
const stat =
|
|
5606
|
-
if (stat.isDirectory() || stat.isSymbolicLink() &&
|
|
5901
|
+
const stat = lstatSync4(source);
|
|
5902
|
+
if (stat.isDirectory() || stat.isSymbolicLink() && existsSync10(join19(source, "SKILL.md"))) {
|
|
5607
5903
|
symlinkSync(source, dest, "junction");
|
|
5608
5904
|
return "link";
|
|
5609
5905
|
}
|
|
@@ -5613,11 +5909,12 @@ function linkOrCopy(source, dest, mode) {
|
|
|
5613
5909
|
symlinkSync(source, dest);
|
|
5614
5910
|
return "link";
|
|
5615
5911
|
} catch {
|
|
5616
|
-
|
|
5912
|
+
copySkillTreeAtomic(source, dest, kind);
|
|
5617
5913
|
return "copy";
|
|
5618
5914
|
}
|
|
5619
5915
|
}
|
|
5620
5916
|
function installBundle(options) {
|
|
5917
|
+
sweepTransientSkillEntries(options.targetDir);
|
|
5621
5918
|
const dest = destinationForBundle(options.targetDir, options.bundle);
|
|
5622
5919
|
if (destinationPresent(dest)) {
|
|
5623
5920
|
if (options.force || isStaleSkillDestination(dest, options.bundle.kind)) {
|
|
@@ -5626,19 +5923,19 @@ function installBundle(options) {
|
|
|
5626
5923
|
throw new AuxiliaryError("FILE_DENIED", `A skill named ${options.bundle.name} already exists`);
|
|
5627
5924
|
}
|
|
5628
5925
|
}
|
|
5629
|
-
const used = linkOrCopy(options.bundle.sourcePath, dest, options.mode);
|
|
5926
|
+
const used = linkOrCopy(options.bundle.sourcePath, dest, options.mode, options.bundle.kind);
|
|
5630
5927
|
return { path: dest, name: options.bundle.name, mode: used };
|
|
5631
5928
|
}
|
|
5632
5929
|
|
|
5633
5930
|
// src/host/instructions-skills/content-revision.ts
|
|
5634
5931
|
import { createHash as createHash7 } from "node:crypto";
|
|
5635
|
-
import { readdirSync as
|
|
5636
|
-
import { join as
|
|
5932
|
+
import { readdirSync as readdirSync6, readFileSync as readFileSync5 } from "node:fs";
|
|
5933
|
+
import { join as join20, relative as relative3 } from "node:path";
|
|
5637
5934
|
function listRelativeFiles(dir, root) {
|
|
5638
5935
|
const entries = [];
|
|
5639
|
-
for (const entry of
|
|
5936
|
+
for (const entry of readdirSync6(dir, { withFileTypes: true })) {
|
|
5640
5937
|
if (entry.name.startsWith(".")) continue;
|
|
5641
|
-
const abs =
|
|
5938
|
+
const abs = join20(dir, entry.name);
|
|
5642
5939
|
if (entry.isDirectory()) {
|
|
5643
5940
|
entries.push(...listRelativeFiles(abs, root));
|
|
5644
5941
|
} else if (entry.isFile()) {
|
|
@@ -5651,22 +5948,116 @@ function contentRevisionOfDir(dir) {
|
|
|
5651
5948
|
const paths = listRelativeFiles(dir, dir).sort();
|
|
5652
5949
|
const aggregate = createHash7("sha256");
|
|
5653
5950
|
for (const relPath of paths) {
|
|
5654
|
-
const contents = readFileSync5(
|
|
5951
|
+
const contents = readFileSync5(join20(dir, relPath));
|
|
5655
5952
|
const fileDigest = createHash7("sha256").update(`${relPath}\0`).update(contents).digest();
|
|
5656
5953
|
aggregate.update(fileDigest);
|
|
5657
5954
|
}
|
|
5658
5955
|
return aggregate.digest("hex");
|
|
5659
5956
|
}
|
|
5660
5957
|
|
|
5958
|
+
// src/host/instructions-skills/install-progress.ts
|
|
5959
|
+
var SKILL_INSTALL_STAGES = [
|
|
5960
|
+
"idle",
|
|
5961
|
+
"resolving",
|
|
5962
|
+
"downloading",
|
|
5963
|
+
"extracting",
|
|
5964
|
+
"cloning",
|
|
5965
|
+
"copying",
|
|
5966
|
+
"finishing"
|
|
5967
|
+
];
|
|
5968
|
+
var bySession2 = /* @__PURE__ */ new Map();
|
|
5969
|
+
function idleSnapshot(sessionId) {
|
|
5970
|
+
return {
|
|
5971
|
+
sessionId,
|
|
5972
|
+
stage: "idle",
|
|
5973
|
+
detail: null,
|
|
5974
|
+
bytesReceived: null,
|
|
5975
|
+
bytesTotal: null,
|
|
5976
|
+
startedAt: null
|
|
5977
|
+
};
|
|
5978
|
+
}
|
|
5979
|
+
function snapshotOf(entry) {
|
|
5980
|
+
return {
|
|
5981
|
+
sessionId: entry.sessionId,
|
|
5982
|
+
stage: entry.stage,
|
|
5983
|
+
detail: entry.detail,
|
|
5984
|
+
bytesReceived: entry.bytesReceived,
|
|
5985
|
+
bytesTotal: entry.bytesTotal,
|
|
5986
|
+
startedAt: entry.startedAt
|
|
5987
|
+
};
|
|
5988
|
+
}
|
|
5989
|
+
function beginSkillInstallProgress(sessionId, detail) {
|
|
5990
|
+
const id = sessionId.trim();
|
|
5991
|
+
if (id === "") return;
|
|
5992
|
+
bySession2.set(id, {
|
|
5993
|
+
sessionId: id,
|
|
5994
|
+
stage: "resolving",
|
|
5995
|
+
detail: detail?.trim() || null,
|
|
5996
|
+
bytesReceived: null,
|
|
5997
|
+
bytesTotal: null,
|
|
5998
|
+
startedAt: Date.now()
|
|
5999
|
+
});
|
|
6000
|
+
}
|
|
6001
|
+
function setSkillInstallStage(sessionId, stage, detail) {
|
|
6002
|
+
const id = sessionId.trim();
|
|
6003
|
+
if (id === "") return;
|
|
6004
|
+
const existing = bySession2.get(id);
|
|
6005
|
+
if (existing === void 0) {
|
|
6006
|
+
bySession2.set(id, {
|
|
6007
|
+
sessionId: id,
|
|
6008
|
+
stage,
|
|
6009
|
+
detail: detail?.trim() || null,
|
|
6010
|
+
bytesReceived: null,
|
|
6011
|
+
bytesTotal: null,
|
|
6012
|
+
startedAt: Date.now()
|
|
6013
|
+
});
|
|
6014
|
+
return;
|
|
6015
|
+
}
|
|
6016
|
+
const prev = existing.stage;
|
|
6017
|
+
existing.stage = stage;
|
|
6018
|
+
if (detail !== void 0) {
|
|
6019
|
+
existing.detail = detail?.trim() || null;
|
|
6020
|
+
}
|
|
6021
|
+
if (stage !== "downloading" && stage !== "cloning" || prev !== stage && (stage === "downloading" || stage === "cloning")) {
|
|
6022
|
+
if (stage !== "downloading" && stage !== "cloning") {
|
|
6023
|
+
existing.bytesReceived = null;
|
|
6024
|
+
existing.bytesTotal = null;
|
|
6025
|
+
} else if (prev !== stage) {
|
|
6026
|
+
existing.bytesReceived = null;
|
|
6027
|
+
existing.bytesTotal = null;
|
|
6028
|
+
}
|
|
6029
|
+
}
|
|
6030
|
+
}
|
|
6031
|
+
function setSkillInstallBytes(sessionId, bytesReceived, bytesTotal) {
|
|
6032
|
+
const id = sessionId.trim();
|
|
6033
|
+
if (id === "") return;
|
|
6034
|
+
const existing = bySession2.get(id);
|
|
6035
|
+
if (existing === void 0) return;
|
|
6036
|
+
existing.bytesReceived = Number.isFinite(bytesReceived) ? Math.max(0, bytesReceived) : null;
|
|
6037
|
+
existing.bytesTotal = bytesTotal !== null && Number.isFinite(bytesTotal) && bytesTotal > 0 ? bytesTotal : null;
|
|
6038
|
+
}
|
|
6039
|
+
function clearSkillInstallProgress(sessionId) {
|
|
6040
|
+
const id = sessionId.trim();
|
|
6041
|
+
if (id === "") return;
|
|
6042
|
+
bySession2.delete(id);
|
|
6043
|
+
}
|
|
6044
|
+
function getSkillInstallProgressSnapshot(sessionId) {
|
|
6045
|
+
const id = sessionId.trim();
|
|
6046
|
+
if (id === "") return idleSnapshot("");
|
|
6047
|
+
const existing = bySession2.get(id);
|
|
6048
|
+
if (existing === void 0) return idleSnapshot(id);
|
|
6049
|
+
return snapshotOf(existing);
|
|
6050
|
+
}
|
|
6051
|
+
|
|
5661
6052
|
// src/host/instructions-skills/install.ts
|
|
5662
6053
|
var execFileAsync3 = promisify3(execFile3);
|
|
5663
6054
|
function tempWorkDir(prefix) {
|
|
5664
|
-
let base =
|
|
6055
|
+
let base = tmpdir3();
|
|
5665
6056
|
try {
|
|
5666
6057
|
base = realpathSync(base);
|
|
5667
6058
|
} catch {
|
|
5668
6059
|
}
|
|
5669
|
-
return mkdtempSync(
|
|
6060
|
+
return mkdtempSync(join21(base, prefix));
|
|
5670
6061
|
}
|
|
5671
6062
|
function execDetail(error) {
|
|
5672
6063
|
if (!(error instanceof Error)) return String(error);
|
|
@@ -5683,49 +6074,109 @@ async function assertGitAvailable(signal) {
|
|
|
5683
6074
|
throw new AuxiliaryError("FILE_EDIT_FAILED", "git is not available on PATH");
|
|
5684
6075
|
}
|
|
5685
6076
|
}
|
|
5686
|
-
|
|
6077
|
+
function parseGitClonePercent(chunk) {
|
|
6078
|
+
const match = /(?:Receiving objects|Resolving deltas):\s+(\d+)%/i.exec(chunk);
|
|
6079
|
+
if (match === null) return null;
|
|
6080
|
+
const value = Number(match[1]);
|
|
6081
|
+
return Number.isFinite(value) ? Math.min(100, Math.max(0, value)) : null;
|
|
6082
|
+
}
|
|
6083
|
+
async function shallowClone(cloneUrl, dest, signal, onClonePercent) {
|
|
5687
6084
|
signal.throwIfAborted();
|
|
5688
6085
|
const attempts = 2;
|
|
5689
6086
|
let lastDetail = "";
|
|
5690
6087
|
for (let i = 0; i < attempts; i += 1) {
|
|
5691
6088
|
signal.throwIfAborted();
|
|
5692
6089
|
try {
|
|
5693
|
-
await
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
6090
|
+
await new Promise((resolveClone, rejectClone) => {
|
|
6091
|
+
const child = spawn(
|
|
6092
|
+
"git",
|
|
6093
|
+
[
|
|
6094
|
+
"-c",
|
|
6095
|
+
"http.version=HTTP/1.1",
|
|
6096
|
+
"clone",
|
|
6097
|
+
"--depth",
|
|
6098
|
+
"1",
|
|
6099
|
+
"--progress",
|
|
6100
|
+
"--",
|
|
6101
|
+
cloneUrl,
|
|
6102
|
+
dest
|
|
6103
|
+
],
|
|
6104
|
+
{ windowsHide: true, stdio: ["ignore", "ignore", "pipe"] }
|
|
6105
|
+
);
|
|
6106
|
+
let stderr = "";
|
|
6107
|
+
const onAbort = () => {
|
|
6108
|
+
try {
|
|
6109
|
+
child.kill();
|
|
6110
|
+
} catch {
|
|
6111
|
+
}
|
|
6112
|
+
};
|
|
6113
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
6114
|
+
child.stderr?.setEncoding("utf8");
|
|
6115
|
+
child.stderr?.on("data", (chunk) => {
|
|
6116
|
+
stderr += chunk;
|
|
6117
|
+
if (stderr.length > 8e3) stderr = stderr.slice(-4e3);
|
|
6118
|
+
const percent = parseGitClonePercent(chunk);
|
|
6119
|
+
if (percent !== null) onClonePercent?.(percent);
|
|
6120
|
+
});
|
|
6121
|
+
child.on("error", (error) => {
|
|
6122
|
+
signal.removeEventListener("abort", onAbort);
|
|
6123
|
+
rejectClone(error);
|
|
6124
|
+
});
|
|
6125
|
+
child.on("close", (code) => {
|
|
6126
|
+
signal.removeEventListener("abort", onAbort);
|
|
6127
|
+
if (signal.aborted) {
|
|
6128
|
+
rejectClone(Object.assign(new Error("Aborted"), { name: "AbortError" }));
|
|
6129
|
+
return;
|
|
6130
|
+
}
|
|
6131
|
+
if (code === 0) {
|
|
6132
|
+
resolveClone();
|
|
6133
|
+
return;
|
|
6134
|
+
}
|
|
6135
|
+
rejectClone(new Error(stderr.trim() || `git clone exited ${String(code)}`));
|
|
6136
|
+
});
|
|
6137
|
+
});
|
|
5698
6138
|
signal.throwIfAborted();
|
|
6139
|
+
onClonePercent?.(100);
|
|
5699
6140
|
return;
|
|
5700
6141
|
} catch (error) {
|
|
6142
|
+
if (error instanceof Error && error.name === "AbortError") throw error;
|
|
5701
6143
|
lastDetail = execDetail(error);
|
|
5702
|
-
|
|
6144
|
+
rmSync4(dest, { recursive: true, force: true });
|
|
5703
6145
|
}
|
|
5704
6146
|
}
|
|
5705
6147
|
throw new AuxiliaryError("FILE_EDIT_FAILED", `git clone failed: ${lastDetail}`);
|
|
5706
6148
|
}
|
|
5707
|
-
async function materializeSkillGitTreeFromSource(source, workDir, signal) {
|
|
6149
|
+
async function materializeSkillGitTreeFromSource(source, workDir, signal, progressSessionId) {
|
|
5708
6150
|
const parsed = (() => {
|
|
5709
6151
|
try {
|
|
5710
6152
|
return parseGitSkillSource(source);
|
|
5711
6153
|
} catch (error) {
|
|
5712
6154
|
const detail = error instanceof Error ? error.message : String(error);
|
|
5713
|
-
throw new AuxiliaryError("
|
|
6155
|
+
throw new AuxiliaryError("FILE_EDIT_FAILED", detail);
|
|
5714
6156
|
}
|
|
5715
6157
|
})();
|
|
5716
|
-
const rootDir = await materializeRepo(parsed, workDir, signal);
|
|
6158
|
+
const rootDir = await materializeRepo(parsed, workDir, signal, progressSessionId);
|
|
5717
6159
|
return { rootDir, parsed };
|
|
5718
6160
|
}
|
|
5719
|
-
async function materializeRepo(parsed, workDir, signal) {
|
|
5720
|
-
const cloneDir =
|
|
6161
|
+
async function materializeRepo(parsed, workDir, signal, progressSessionId) {
|
|
6162
|
+
const cloneDir = join21(workDir, "repo");
|
|
5721
6163
|
const archiveErrors = [];
|
|
6164
|
+
const sessionId = progressSessionId?.trim() ?? "";
|
|
5722
6165
|
if (parsed.github !== null) {
|
|
5723
6166
|
try {
|
|
5724
6167
|
return await fetchGithubRepoArchive({
|
|
5725
6168
|
owner: parsed.github.owner,
|
|
5726
6169
|
repo: parsed.github.repo,
|
|
5727
6170
|
workDir,
|
|
5728
|
-
signal
|
|
6171
|
+
signal,
|
|
6172
|
+
onStage: (stage, detail) => {
|
|
6173
|
+
if (sessionId === "") return;
|
|
6174
|
+
setSkillInstallStage(sessionId, stage, detail ?? parsed.label);
|
|
6175
|
+
},
|
|
6176
|
+
onDownloadProgress: (received, total) => {
|
|
6177
|
+
if (sessionId === "") return;
|
|
6178
|
+
setSkillInstallBytes(sessionId, received, total);
|
|
6179
|
+
}
|
|
5729
6180
|
});
|
|
5730
6181
|
} catch (error) {
|
|
5731
6182
|
if (error instanceof Error && error.name === "AbortError") throw error;
|
|
@@ -5733,8 +6184,12 @@ async function materializeRepo(parsed, workDir, signal) {
|
|
|
5733
6184
|
}
|
|
5734
6185
|
}
|
|
5735
6186
|
await assertGitAvailable(signal);
|
|
6187
|
+
if (sessionId !== "") setSkillInstallStage(sessionId, "cloning", parsed.label);
|
|
5736
6188
|
try {
|
|
5737
|
-
await shallowClone(parsed.cloneUrl, cloneDir, signal)
|
|
6189
|
+
await shallowClone(parsed.cloneUrl, cloneDir, signal, (percent) => {
|
|
6190
|
+
if (sessionId === "") return;
|
|
6191
|
+
setSkillInstallBytes(sessionId, percent, 100);
|
|
6192
|
+
});
|
|
5738
6193
|
return cloneDir;
|
|
5739
6194
|
} catch (cloneError) {
|
|
5740
6195
|
const cloneDetail = cloneError instanceof Error ? cloneError.message : String(cloneError);
|
|
@@ -5747,11 +6202,13 @@ async function materializeRepo(parsed, workDir, signal) {
|
|
|
5747
6202
|
}
|
|
5748
6203
|
async function installSkillsFromGit(options) {
|
|
5749
6204
|
const tempRoot = tempWorkDir("ae-skill-git-");
|
|
6205
|
+
const progressSessionId = options.progressSessionId?.trim() ?? "";
|
|
5750
6206
|
try {
|
|
5751
6207
|
const { rootDir: cloneDir, parsed: materialized } = await materializeSkillGitTreeFromSource(
|
|
5752
6208
|
options.source,
|
|
5753
6209
|
tempRoot,
|
|
5754
|
-
options.signal
|
|
6210
|
+
options.signal,
|
|
6211
|
+
progressSessionId === "" ? void 0 : progressSessionId
|
|
5755
6212
|
);
|
|
5756
6213
|
const bundles = resolveBundlesFromClone(cloneDir, materialized.subpath);
|
|
5757
6214
|
if (bundles.length === 0) {
|
|
@@ -5763,63 +6220,94 @@ async function installSkillsFromGit(options) {
|
|
|
5763
6220
|
const targetDir = installTargetDir(
|
|
5764
6221
|
options.target,
|
|
5765
6222
|
options.projectRoot,
|
|
5766
|
-
agentsHomeOf(options.env)
|
|
6223
|
+
agentsHomeOf(options.env),
|
|
6224
|
+
dshHomeOf(options.env)
|
|
5767
6225
|
);
|
|
6226
|
+
if (progressSessionId !== "") {
|
|
6227
|
+
setSkillInstallStage(progressSessionId, "copying", materialized.label);
|
|
6228
|
+
}
|
|
5768
6229
|
const installed = [];
|
|
6230
|
+
const skippedBusy = [];
|
|
5769
6231
|
for (const bundle of bundles) {
|
|
5770
6232
|
options.signal.throwIfAborted();
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
cwd: options.projectRoot,
|
|
5779
|
-
projectRoot: options.projectRoot,
|
|
5780
|
-
env: options.env
|
|
5781
|
-
});
|
|
6233
|
+
try {
|
|
6234
|
+
if (progressSessionId !== "") {
|
|
6235
|
+
setSkillInstallStage(
|
|
6236
|
+
progressSessionId,
|
|
6237
|
+
"copying",
|
|
6238
|
+
`${bundle.name} \xB7 ${installed.length + skippedBusy.length + 1}/${bundles.length}`
|
|
6239
|
+
);
|
|
5782
6240
|
}
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
mode: "copy"
|
|
5789
|
-
});
|
|
5790
|
-
installed.push(result);
|
|
5791
|
-
const ledgerRoot = options.installLedgerRoot?.trim();
|
|
5792
|
-
if (ledgerRoot !== void 0 && ledgerRoot !== "") {
|
|
5793
|
-
upsertInstallRecord(ledgerRoot, {
|
|
5794
|
-
name: result.name,
|
|
5795
|
-
channel: "github",
|
|
5796
|
-
source: options.source.trim(),
|
|
5797
|
-
contentRevision: contentRevisionOfDir(result.path),
|
|
5798
|
-
installedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5799
|
-
updateCheck: true
|
|
6241
|
+
const result = installBundle({
|
|
6242
|
+
bundle,
|
|
6243
|
+
targetDir,
|
|
6244
|
+
force: options.force,
|
|
6245
|
+
mode: "copy"
|
|
5800
6246
|
});
|
|
6247
|
+
installed.push(result);
|
|
6248
|
+
if (options.force) {
|
|
6249
|
+
const folderName = basename11(bundle.sourcePath);
|
|
6250
|
+
const names = /* @__PURE__ */ new Set([bundle.name]);
|
|
6251
|
+
if (isKebabCaseName(folderName)) names.add(folderName);
|
|
6252
|
+
for (const name2 of names) {
|
|
6253
|
+
purgeManagedSkillName({
|
|
6254
|
+
name: name2,
|
|
6255
|
+
cwd: options.projectRoot,
|
|
6256
|
+
projectRoot: options.projectRoot,
|
|
6257
|
+
env: options.env,
|
|
6258
|
+
exceptPaths: name2 === result.name ? [result.path] : []
|
|
6259
|
+
});
|
|
6260
|
+
}
|
|
6261
|
+
}
|
|
6262
|
+
const ledgerRoot = options.installLedgerRoot?.trim();
|
|
6263
|
+
if (ledgerRoot !== void 0 && ledgerRoot !== "") {
|
|
6264
|
+
upsertInstallRecord(ledgerRoot, {
|
|
6265
|
+
name: result.name,
|
|
6266
|
+
channel: "github",
|
|
6267
|
+
source: options.source.trim(),
|
|
6268
|
+
contentRevision: contentRevisionOfDir(result.path),
|
|
6269
|
+
installedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6270
|
+
updateCheck: true
|
|
6271
|
+
});
|
|
6272
|
+
}
|
|
6273
|
+
} catch (error) {
|
|
6274
|
+
if (isWindowsPathBusyError(error) || error instanceof AuxiliaryError && error.code === "FILE_EDIT_FAILED" && isWindowsPathBusyError(error)) {
|
|
6275
|
+
skippedBusy.push(bundle.name);
|
|
6276
|
+
continue;
|
|
6277
|
+
}
|
|
6278
|
+
if (error instanceof AuxiliaryError && error.code === "FILE_EDIT_FAILED" && /still present|file in use|EPERM|EIO/i.test(error.message)) {
|
|
6279
|
+
skippedBusy.push(bundle.name);
|
|
6280
|
+
continue;
|
|
6281
|
+
}
|
|
6282
|
+
throw error;
|
|
5801
6283
|
}
|
|
5802
6284
|
}
|
|
5803
|
-
|
|
6285
|
+
if (installed.length === 0 && skippedBusy.length > 0) {
|
|
6286
|
+
throw new AuxiliaryError(
|
|
6287
|
+
"FILE_EDIT_FAILED",
|
|
6288
|
+
`Failed to update ${skippedBusy[0]}: still present (EPERM / EIO / file in use \u2014 close skill preview or Desktop file tabs, then retry)`
|
|
6289
|
+
);
|
|
6290
|
+
}
|
|
6291
|
+
return { installed, skippedBusy };
|
|
5804
6292
|
} finally {
|
|
5805
6293
|
try {
|
|
5806
|
-
|
|
6294
|
+
rmSync4(tempRoot, { recursive: true, force: true });
|
|
5807
6295
|
} catch {
|
|
5808
6296
|
}
|
|
5809
6297
|
}
|
|
5810
6298
|
}
|
|
5811
6299
|
|
|
5812
6300
|
// src/host/instructions-skills/update-check.ts
|
|
5813
|
-
import { mkdtempSync as mkdtempSync2, realpathSync as realpathSync2, rmSync as
|
|
5814
|
-
import { tmpdir as
|
|
5815
|
-
import { join as
|
|
6301
|
+
import { mkdtempSync as mkdtempSync2, realpathSync as realpathSync2, rmSync as rmSync5 } from "node:fs";
|
|
6302
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
6303
|
+
import { join as join22 } from "node:path";
|
|
5816
6304
|
function tempWorkDir2(prefix) {
|
|
5817
|
-
let base =
|
|
6305
|
+
let base = tmpdir4();
|
|
5818
6306
|
try {
|
|
5819
6307
|
base = realpathSync2(base);
|
|
5820
6308
|
} catch {
|
|
5821
6309
|
}
|
|
5822
|
-
return mkdtempSync2(
|
|
6310
|
+
return mkdtempSync2(join22(base, prefix));
|
|
5823
6311
|
}
|
|
5824
6312
|
function revisionPathForBundle(bundle) {
|
|
5825
6313
|
return bundle.kind === "directory" ? bundle.sourcePath : bundle.sourcePath;
|
|
@@ -5870,7 +6358,7 @@ async function checkGithubSkillUpdate(record2, options) {
|
|
|
5870
6358
|
return noUpdate(label, true);
|
|
5871
6359
|
} finally {
|
|
5872
6360
|
try {
|
|
5873
|
-
|
|
6361
|
+
rmSync5(tempRoot, { recursive: true, force: true });
|
|
5874
6362
|
} catch {
|
|
5875
6363
|
}
|
|
5876
6364
|
}
|
|
@@ -5878,18 +6366,18 @@ async function checkGithubSkillUpdate(record2, options) {
|
|
|
5878
6366
|
|
|
5879
6367
|
// src/host/instructions-skills/zip-install.ts
|
|
5880
6368
|
import { execFile as execFile4 } from "node:child_process";
|
|
5881
|
-
import { existsSync as
|
|
5882
|
-
import { tmpdir as
|
|
5883
|
-
import { basename as
|
|
6369
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync3, realpathSync as realpathSync3, rmSync as rmSync6 } from "node:fs";
|
|
6370
|
+
import { tmpdir as tmpdir5 } from "node:os";
|
|
6371
|
+
import { basename as basename12, join as join23, resolve as resolve14 } from "node:path";
|
|
5884
6372
|
import { promisify as promisify4 } from "node:util";
|
|
5885
6373
|
var execFileAsync4 = promisify4(execFile4);
|
|
5886
6374
|
function tempWorkDir3(prefix) {
|
|
5887
|
-
let base =
|
|
6375
|
+
let base = tmpdir5();
|
|
5888
6376
|
try {
|
|
5889
6377
|
base = realpathSync3(base);
|
|
5890
6378
|
} catch {
|
|
5891
6379
|
}
|
|
5892
|
-
return mkdtempSync3(
|
|
6380
|
+
return mkdtempSync3(join23(base, prefix));
|
|
5893
6381
|
}
|
|
5894
6382
|
async function extractZipArchive(zipPath, destDir, signal) {
|
|
5895
6383
|
signal.throwIfAborted();
|
|
@@ -5906,15 +6394,15 @@ async function extractZipArchive(zipPath, destDir, signal) {
|
|
|
5906
6394
|
signal.throwIfAborted();
|
|
5907
6395
|
}
|
|
5908
6396
|
async function installSkillsFromZipFile(options) {
|
|
5909
|
-
const zipPath =
|
|
5910
|
-
if (!
|
|
6397
|
+
const zipPath = resolve14(options.zipPath);
|
|
6398
|
+
if (!existsSync12(zipPath)) {
|
|
5911
6399
|
throw new AuxiliaryError("FILE_NOT_FOUND", `Zip not found: ${zipPath}`);
|
|
5912
6400
|
}
|
|
5913
6401
|
if (!zipPath.toLowerCase().endsWith(".zip")) {
|
|
5914
|
-
throw new AuxiliaryError("FILE_DENIED", `Expected a .zip archive: ${
|
|
6402
|
+
throw new AuxiliaryError("FILE_DENIED", `Expected a .zip archive: ${basename12(zipPath)}`);
|
|
5915
6403
|
}
|
|
5916
6404
|
const workDir = tempWorkDir3("ae-skill-zip-");
|
|
5917
|
-
const extractDir =
|
|
6405
|
+
const extractDir = join23(workDir, "extract");
|
|
5918
6406
|
try {
|
|
5919
6407
|
await extractZipArchive(zipPath, extractDir, options.signal);
|
|
5920
6408
|
const root = unwrapArchiveRoot(extractDir);
|
|
@@ -5928,13 +6416,21 @@ async function installSkillsFromZipFile(options) {
|
|
|
5928
6416
|
const targetDir = installTargetDir(
|
|
5929
6417
|
options.target,
|
|
5930
6418
|
options.projectRoot,
|
|
5931
|
-
agentsHomeOf(options.env)
|
|
6419
|
+
agentsHomeOf(options.env),
|
|
6420
|
+
dshHomeOf(options.env)
|
|
5932
6421
|
);
|
|
5933
6422
|
const installed = [];
|
|
5934
6423
|
for (const bundle of bundles) {
|
|
5935
6424
|
options.signal.throwIfAborted();
|
|
6425
|
+
const result = installBundle({
|
|
6426
|
+
bundle,
|
|
6427
|
+
targetDir,
|
|
6428
|
+
force: options.force,
|
|
6429
|
+
mode: "copy"
|
|
6430
|
+
});
|
|
6431
|
+
installed.push(result);
|
|
5936
6432
|
if (options.force) {
|
|
5937
|
-
const folderName =
|
|
6433
|
+
const folderName = basename12(bundle.sourcePath);
|
|
5938
6434
|
const names = /* @__PURE__ */ new Set([bundle.name]);
|
|
5939
6435
|
if (isKebabCaseName(folderName)) names.add(folderName);
|
|
5940
6436
|
for (const name2 of names) {
|
|
@@ -5942,17 +6438,11 @@ async function installSkillsFromZipFile(options) {
|
|
|
5942
6438
|
name: name2,
|
|
5943
6439
|
cwd: options.projectRoot,
|
|
5944
6440
|
projectRoot: options.projectRoot,
|
|
5945
|
-
env: options.env
|
|
6441
|
+
env: options.env,
|
|
6442
|
+
exceptPaths: name2 === result.name ? [result.path] : []
|
|
5946
6443
|
});
|
|
5947
6444
|
}
|
|
5948
6445
|
}
|
|
5949
|
-
const result = installBundle({
|
|
5950
|
-
bundle,
|
|
5951
|
-
targetDir,
|
|
5952
|
-
force: options.force,
|
|
5953
|
-
mode: "copy"
|
|
5954
|
-
});
|
|
5955
|
-
installed.push(result);
|
|
5956
6446
|
const ledgerRoot = options.installLedgerRoot?.trim();
|
|
5957
6447
|
if (ledgerRoot !== void 0 && ledgerRoot !== "") {
|
|
5958
6448
|
upsertInstallRecord(ledgerRoot, {
|
|
@@ -5968,7 +6458,7 @@ async function installSkillsFromZipFile(options) {
|
|
|
5968
6458
|
return installed;
|
|
5969
6459
|
} finally {
|
|
5970
6460
|
try {
|
|
5971
|
-
|
|
6461
|
+
rmSync6(workDir, { recursive: true, force: true });
|
|
5972
6462
|
} catch {
|
|
5973
6463
|
}
|
|
5974
6464
|
}
|
|
@@ -5977,11 +6467,11 @@ async function installSkillsFromZipFile(options) {
|
|
|
5977
6467
|
// src/host/instructions-skills/io.ts
|
|
5978
6468
|
function sessionCwd3(session) {
|
|
5979
6469
|
const header = session?.header;
|
|
5980
|
-
if (typeof header?.cwd === "string" && header.cwd.trim() !== "") return
|
|
6470
|
+
if (typeof header?.cwd === "string" && header.cwd.trim() !== "") return resolve15(header.cwd);
|
|
5981
6471
|
try {
|
|
5982
6472
|
const requested = session?.requestHeader?.();
|
|
5983
6473
|
if (typeof requested?.cwd === "string" && requested.cwd.trim() !== "") {
|
|
5984
|
-
return
|
|
6474
|
+
return resolve15(requested.cwd);
|
|
5985
6475
|
}
|
|
5986
6476
|
} catch {
|
|
5987
6477
|
}
|
|
@@ -6037,6 +6527,7 @@ async function enrichSkillsFromLedger(skills, options) {
|
|
|
6037
6527
|
return skills.map((skill) => ({ ...defaultSkillInstallMeta(), ...skill }));
|
|
6038
6528
|
}
|
|
6039
6529
|
const ledger = readInstallLedger(ledgerRoot);
|
|
6530
|
+
const checkUpdates = options.checkUpdates === true;
|
|
6040
6531
|
const out = [];
|
|
6041
6532
|
for (const skill of skills) {
|
|
6042
6533
|
const record2 = ledger[skill.name];
|
|
@@ -6050,7 +6541,7 @@ async function enrichSkillsFromLedger(skills, options) {
|
|
|
6050
6541
|
installChannel: record2.channel,
|
|
6051
6542
|
updateSourceLabel: ledgerSourceLabel(record2.source)
|
|
6052
6543
|
};
|
|
6053
|
-
if (record2.channel === "github" && record2.updateCheck) {
|
|
6544
|
+
if (checkUpdates && record2.channel === "github" && record2.updateCheck) {
|
|
6054
6545
|
try {
|
|
6055
6546
|
const check = await checkGithubSkillUpdate(record2, { signal: options.signal });
|
|
6056
6547
|
entry = {
|
|
@@ -6074,13 +6565,24 @@ async function enrichSkillsFromLedger(skills, options) {
|
|
|
6074
6565
|
}
|
|
6075
6566
|
function inferSkillInstallTarget(name2, cwd, projectRoot, env = process.env) {
|
|
6076
6567
|
const roots = skillRootsFor(cwd, projectRoot, env);
|
|
6077
|
-
const projectAgents =
|
|
6078
|
-
const projectDsh =
|
|
6568
|
+
const projectAgents = join24(resolve15(projectRoot), ".agents", "skills");
|
|
6569
|
+
const projectDsh = join24(resolve15(projectRoot), ".dsh", "skills");
|
|
6570
|
+
const userAgents = join24(agentsHomeOf(env), "skills");
|
|
6571
|
+
const userDsh = join24(dshHomeOf(env), "skills");
|
|
6079
6572
|
for (const root of roots) {
|
|
6080
|
-
const present =
|
|
6573
|
+
const present = existsSync13(join24(root, name2, "SKILL.md")) || existsSync13(join24(root, `${name2}.md`));
|
|
6081
6574
|
if (!present) continue;
|
|
6082
|
-
if (samePath2(root, projectAgents)
|
|
6083
|
-
return "
|
|
6575
|
+
if (samePath2(root, projectAgents)) return "project";
|
|
6576
|
+
if (samePath2(root, projectDsh)) return "project-dsh";
|
|
6577
|
+
if (samePath2(root, userAgents)) return "user";
|
|
6578
|
+
if (samePath2(root, userDsh)) return "user-dsh";
|
|
6579
|
+
const normalized = root.toLowerCase().split(/[/\\]/).join(sep7);
|
|
6580
|
+
const dshMarker = `${sep7}.dsh${sep7}skills`;
|
|
6581
|
+
const underProject = isInsideOrSame(resolve15(projectRoot), root);
|
|
6582
|
+
if (normalized.includes(dshMarker) || normalized.endsWith(`${sep7}.dsh${sep7}skills`)) {
|
|
6583
|
+
return underProject ? "project-dsh" : "user-dsh";
|
|
6584
|
+
}
|
|
6585
|
+
return underProject ? "project" : "user";
|
|
6084
6586
|
}
|
|
6085
6587
|
throw new AuxiliaryError("FILE_NOT_FOUND", `Skill is not installed in a managed skills root: ${name2}`);
|
|
6086
6588
|
}
|
|
@@ -6098,7 +6600,8 @@ async function buildSnapshot(ctx, sessionId, cwd, options) {
|
|
|
6098
6600
|
const signal = options?.signal ?? new AbortController().signal;
|
|
6099
6601
|
const skills = await enrichSkillsFromLedger(merged.skills, {
|
|
6100
6602
|
installLedgerRoot: options?.installLedgerRoot,
|
|
6101
|
-
signal
|
|
6603
|
+
signal,
|
|
6604
|
+
checkUpdates: options?.checkUpdates === true
|
|
6102
6605
|
});
|
|
6103
6606
|
return {
|
|
6104
6607
|
sessionId,
|
|
@@ -6116,7 +6619,8 @@ async function listInstructionsSkillsNow(options) {
|
|
|
6116
6619
|
options.signal.throwIfAborted();
|
|
6117
6620
|
return buildSnapshot(options.ctx, options.request.sessionId, cwd, {
|
|
6118
6621
|
installLedgerRoot: options.installLedgerRoot,
|
|
6119
|
-
signal: options.signal
|
|
6622
|
+
signal: options.signal,
|
|
6623
|
+
checkUpdates: options.request.checkUpdates === true
|
|
6120
6624
|
});
|
|
6121
6625
|
}
|
|
6122
6626
|
async function createWorkspaceAgentsNow(options) {
|
|
@@ -6147,24 +6651,36 @@ async function createWorkspaceSkillNow(options) {
|
|
|
6147
6651
|
}
|
|
6148
6652
|
async function installSkillFromGitNow(options) {
|
|
6149
6653
|
options.signal.throwIfAborted();
|
|
6150
|
-
const
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6654
|
+
const sessionId = String(options.request.sessionId);
|
|
6655
|
+
beginSkillInstallProgress(sessionId, options.request.source);
|
|
6656
|
+
try {
|
|
6657
|
+
const agent = agentOf2(options.ctx, options.request.sessionId);
|
|
6658
|
+
const cwd = sessionCwd3(agent.session);
|
|
6659
|
+
const discovered = discoverInstructionFiles({ cwd });
|
|
6660
|
+
const batch = await installSkillsFromGit({
|
|
6661
|
+
source: options.request.source,
|
|
6662
|
+
target: options.request.target,
|
|
6663
|
+
projectRoot: discovered.projectRoot,
|
|
6664
|
+
// Panel installs overwrite by default; pass force: false to refuse collisions.
|
|
6665
|
+
force: options.request.force !== false,
|
|
6666
|
+
signal: options.signal,
|
|
6667
|
+
installLedgerRoot: options.installLedgerRoot,
|
|
6668
|
+
progressSessionId: sessionId
|
|
6669
|
+
});
|
|
6670
|
+
options.signal.throwIfAborted();
|
|
6671
|
+
setSkillInstallStage(sessionId, "finishing", options.request.source);
|
|
6672
|
+
const snapshot = await buildSnapshot(options.ctx, options.request.sessionId, cwd, {
|
|
6673
|
+
installLedgerRoot: options.installLedgerRoot,
|
|
6674
|
+
signal: options.signal
|
|
6675
|
+
});
|
|
6676
|
+
return {
|
|
6677
|
+
installed: batch.installed,
|
|
6678
|
+
skippedBusy: batch.skippedBusy,
|
|
6679
|
+
snapshot
|
|
6680
|
+
};
|
|
6681
|
+
} finally {
|
|
6682
|
+
clearSkillInstallProgress(sessionId);
|
|
6683
|
+
}
|
|
6168
6684
|
}
|
|
6169
6685
|
async function installSkillFromZipNow(options) {
|
|
6170
6686
|
options.signal.throwIfAborted();
|
|
@@ -6235,40 +6751,48 @@ async function updateSkillFromGitNow(options) {
|
|
|
6235
6751
|
if (source === "") {
|
|
6236
6752
|
throw new AuxiliaryError("FILE_DENIED", "Install record is missing a git source");
|
|
6237
6753
|
}
|
|
6238
|
-
const
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
cwd
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
target,
|
|
6249
|
-
projectRoot: discovered.projectRoot,
|
|
6250
|
-
force: true,
|
|
6251
|
-
signal: options.signal,
|
|
6252
|
-
installLedgerRoot: ledgerRoot
|
|
6253
|
-
});
|
|
6254
|
-
options.signal.throwIfAborted();
|
|
6255
|
-
const updated = installed.find((entry) => entry.name === options.request.name);
|
|
6256
|
-
if (updated === void 0) {
|
|
6257
|
-
throw new AuxiliaryError(
|
|
6258
|
-
"FILE_NOT_FOUND",
|
|
6259
|
-
`Skill ${options.request.name} was not present in the git source`
|
|
6754
|
+
const sessionId = String(options.request.sessionId);
|
|
6755
|
+
beginSkillInstallProgress(sessionId, source);
|
|
6756
|
+
try {
|
|
6757
|
+
const agent = agentOf2(options.ctx, options.request.sessionId);
|
|
6758
|
+
const cwd = sessionCwd3(agent.session);
|
|
6759
|
+
const discovered = discoverInstructionFiles({ cwd });
|
|
6760
|
+
const target = inferSkillInstallTarget(
|
|
6761
|
+
options.request.name,
|
|
6762
|
+
cwd,
|
|
6763
|
+
discovered.projectRoot
|
|
6260
6764
|
);
|
|
6765
|
+
const batch = await installSkillsFromGit({
|
|
6766
|
+
source,
|
|
6767
|
+
target,
|
|
6768
|
+
projectRoot: discovered.projectRoot,
|
|
6769
|
+
force: true,
|
|
6770
|
+
signal: options.signal,
|
|
6771
|
+
installLedgerRoot: ledgerRoot,
|
|
6772
|
+
progressSessionId: sessionId
|
|
6773
|
+
});
|
|
6774
|
+
options.signal.throwIfAborted();
|
|
6775
|
+
const updated = batch.installed.find((entry) => entry.name === options.request.name);
|
|
6776
|
+
if (updated === void 0) {
|
|
6777
|
+
throw new AuxiliaryError(
|
|
6778
|
+
"FILE_NOT_FOUND",
|
|
6779
|
+
`Skill ${options.request.name} was not present in the git source`
|
|
6780
|
+
);
|
|
6781
|
+
}
|
|
6782
|
+
setSkillInstallStage(sessionId, "finishing", source);
|
|
6783
|
+
const snapshot = await buildSnapshot(options.ctx, options.request.sessionId, cwd, {
|
|
6784
|
+
installLedgerRoot: ledgerRoot,
|
|
6785
|
+
signal: options.signal
|
|
6786
|
+
});
|
|
6787
|
+
return { updated, snapshot };
|
|
6788
|
+
} finally {
|
|
6789
|
+
clearSkillInstallProgress(sessionId);
|
|
6261
6790
|
}
|
|
6262
|
-
const snapshot = await buildSnapshot(options.ctx, options.request.sessionId, cwd, {
|
|
6263
|
-
installLedgerRoot: ledgerRoot,
|
|
6264
|
-
signal: options.signal
|
|
6265
|
-
});
|
|
6266
|
-
return { updated, snapshot };
|
|
6267
6791
|
}
|
|
6268
6792
|
function skillDocumentAbsolutePath(path) {
|
|
6269
6793
|
const trimmed = path.replace(/[/\\]+$/, "");
|
|
6270
|
-
if (/\.md$/i.test(trimmed)) return
|
|
6271
|
-
return
|
|
6794
|
+
if (/\.md$/i.test(trimmed)) return resolve15(trimmed);
|
|
6795
|
+
return resolve15(trimmed, "SKILL.md");
|
|
6272
6796
|
}
|
|
6273
6797
|
async function readSkillDocumentNow(options) {
|
|
6274
6798
|
options.signal.throwIfAborted();
|
|
@@ -6280,11 +6804,11 @@ async function readSkillDocumentNow(options) {
|
|
|
6280
6804
|
if (!roots.some((root) => isInsideOrSame(root, absolutePath2))) {
|
|
6281
6805
|
throw new AuxiliaryError("FILE_DENIED", "Skill document is outside preview roots");
|
|
6282
6806
|
}
|
|
6283
|
-
if (
|
|
6807
|
+
if (basename13(absolutePath2).toLowerCase() !== "skill.md") {
|
|
6284
6808
|
throw new AuxiliaryError("FILE_DENIED", "Only SKILL.md may be previewed");
|
|
6285
6809
|
}
|
|
6286
6810
|
options.signal.throwIfAborted();
|
|
6287
|
-
if (!
|
|
6811
|
+
if (!existsSync13(absolutePath2)) {
|
|
6288
6812
|
throw new AuxiliaryError("FILE_NOT_FOUND", "Skill document not found");
|
|
6289
6813
|
}
|
|
6290
6814
|
try {
|
|
@@ -6319,7 +6843,7 @@ async function readSkillDocumentNow(options) {
|
|
|
6319
6843
|
}
|
|
6320
6844
|
|
|
6321
6845
|
// src/host/mcp-connectors/io.ts
|
|
6322
|
-
import { existsSync as
|
|
6846
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
6323
6847
|
|
|
6324
6848
|
// src/host/mcp-connectors/validate.ts
|
|
6325
6849
|
var MCP_SERVER_NAME_PATTERN = /^[A-Za-z0-9_-]{1,32}$/;
|
|
@@ -6441,22 +6965,22 @@ function parseMcpJsonText(jsonText) {
|
|
|
6441
6965
|
}
|
|
6442
6966
|
|
|
6443
6967
|
// src/host/mcp-connectors/install-git.ts
|
|
6444
|
-
import { existsSync as
|
|
6445
|
-
import { join as
|
|
6968
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync7, readFileSync as readFileSync7, renameSync as renameSync6, rmSync as rmSync7 } from "node:fs";
|
|
6969
|
+
import { join as join26 } from "node:path";
|
|
6446
6970
|
|
|
6447
6971
|
// src/host/mcp-connectors/paths.ts
|
|
6448
|
-
import { join as
|
|
6972
|
+
import { join as join25 } from "node:path";
|
|
6449
6973
|
function mcpConnectorsRoot(pluginDataPackageRoot) {
|
|
6450
|
-
return
|
|
6974
|
+
return join25(pluginDataPackageRoot, "mcp-connectors");
|
|
6451
6975
|
}
|
|
6452
6976
|
function mcpConnectorsLedgerPath(root) {
|
|
6453
|
-
return
|
|
6977
|
+
return join25(root, "mcp-connectors.json");
|
|
6454
6978
|
}
|
|
6455
6979
|
function mcpServersRoot(root) {
|
|
6456
|
-
return
|
|
6980
|
+
return join25(root, "mcp-servers");
|
|
6457
6981
|
}
|
|
6458
6982
|
function mcpServerInstallDir(root, id) {
|
|
6459
|
-
return
|
|
6983
|
+
return join25(mcpServersRoot(root), id);
|
|
6460
6984
|
}
|
|
6461
6985
|
|
|
6462
6986
|
// src/host/mcp-connectors/install-git.ts
|
|
@@ -6473,8 +6997,8 @@ function inferStdioFromPackageJson(installDir, override) {
|
|
|
6473
6997
|
cwd: installDir
|
|
6474
6998
|
};
|
|
6475
6999
|
}
|
|
6476
|
-
const pkgPath =
|
|
6477
|
-
if (!
|
|
7000
|
+
const pkgPath = join26(installDir, "package.json");
|
|
7001
|
+
if (!existsSync14(pkgPath)) {
|
|
6478
7002
|
return {
|
|
6479
7003
|
transport: "stdio",
|
|
6480
7004
|
command: "npx",
|
|
@@ -6491,7 +7015,7 @@ function inferStdioFromPackageJson(installDir, override) {
|
|
|
6491
7015
|
return {
|
|
6492
7016
|
transport: "stdio",
|
|
6493
7017
|
command: process.execPath,
|
|
6494
|
-
args: [
|
|
7018
|
+
args: [join26(installDir, bin)],
|
|
6495
7019
|
env: {},
|
|
6496
7020
|
cwd: installDir
|
|
6497
7021
|
};
|
|
@@ -6504,7 +7028,7 @@ function inferStdioFromPackageJson(installDir, override) {
|
|
|
6504
7028
|
return {
|
|
6505
7029
|
transport: "stdio",
|
|
6506
7030
|
command: process.execPath,
|
|
6507
|
-
args: [
|
|
7031
|
+
args: [join26(installDir, first)],
|
|
6508
7032
|
env: {},
|
|
6509
7033
|
cwd: installDir
|
|
6510
7034
|
};
|
|
@@ -6514,7 +7038,7 @@ function inferStdioFromPackageJson(installDir, override) {
|
|
|
6514
7038
|
return {
|
|
6515
7039
|
transport: "stdio",
|
|
6516
7040
|
command: process.execPath,
|
|
6517
|
-
args: [
|
|
7041
|
+
args: [join26(installDir, pkg.main)],
|
|
6518
7042
|
env: {},
|
|
6519
7043
|
cwd: installDir
|
|
6520
7044
|
};
|
|
@@ -6533,16 +7057,16 @@ function inferStdioFromPackageJson(installDir, override) {
|
|
|
6533
7057
|
async function installMcpServerFromGit(options) {
|
|
6534
7058
|
const parsed = parseGitSkillSource(options.source);
|
|
6535
7059
|
const installDir = mcpServerInstallDir(options.rootDir, options.id);
|
|
6536
|
-
if (
|
|
7060
|
+
if (existsSync14(installDir)) {
|
|
6537
7061
|
if (!options.force) {
|
|
6538
7062
|
throw new AuxiliaryError("FILE_EDIT_FAILED", `MCP install dir already exists: ${installDir}`);
|
|
6539
7063
|
}
|
|
6540
7064
|
removePathRobust(installDir);
|
|
6541
7065
|
}
|
|
6542
|
-
mkdirSync7(
|
|
7066
|
+
mkdirSync7(join26(options.rootDir, "mcp-servers"), { recursive: true });
|
|
6543
7067
|
const staging = `${installDir}.staging.${process.pid}`;
|
|
6544
7068
|
try {
|
|
6545
|
-
if (
|
|
7069
|
+
if (existsSync14(staging)) removePathRobust(staging);
|
|
6546
7070
|
mkdirSync7(staging, { recursive: true });
|
|
6547
7071
|
if (parsed.github === null) {
|
|
6548
7072
|
throw new AuxiliaryError(
|
|
@@ -6559,20 +7083,20 @@ async function installMcpServerFromGit(options) {
|
|
|
6559
7083
|
options.signal.throwIfAborted();
|
|
6560
7084
|
let contentRoot = repoDir;
|
|
6561
7085
|
if (parsed.subpath !== null) {
|
|
6562
|
-
const nested =
|
|
6563
|
-
if (!
|
|
7086
|
+
const nested = join26(repoDir, parsed.subpath);
|
|
7087
|
+
if (!existsSync14(nested)) {
|
|
6564
7088
|
throw new AuxiliaryError("FILE_EDIT_FAILED", `Subpath not found in repo: ${parsed.subpath}`);
|
|
6565
7089
|
}
|
|
6566
7090
|
contentRoot = nested;
|
|
6567
7091
|
}
|
|
6568
|
-
mkdirSync7(
|
|
7092
|
+
mkdirSync7(join26(options.rootDir, "mcp-servers"), { recursive: true });
|
|
6569
7093
|
if (contentRoot !== repoDir) {
|
|
6570
7094
|
const nestedStaging = `${installDir}.nested.${process.pid}`;
|
|
6571
|
-
|
|
7095
|
+
renameSync6(contentRoot, nestedStaging);
|
|
6572
7096
|
removePathRobust(staging);
|
|
6573
|
-
|
|
7097
|
+
renameSync6(nestedStaging, installDir);
|
|
6574
7098
|
} else {
|
|
6575
|
-
|
|
7099
|
+
renameSync6(repoDir, installDir);
|
|
6576
7100
|
try {
|
|
6577
7101
|
removePathRobust(staging);
|
|
6578
7102
|
} catch {
|
|
@@ -6580,11 +7104,11 @@ async function installMcpServerFromGit(options) {
|
|
|
6580
7104
|
}
|
|
6581
7105
|
} catch (error) {
|
|
6582
7106
|
try {
|
|
6583
|
-
if (
|
|
7107
|
+
if (existsSync14(staging)) rmSync7(staging, { recursive: true, force: true });
|
|
6584
7108
|
} catch {
|
|
6585
7109
|
}
|
|
6586
7110
|
try {
|
|
6587
|
-
if (
|
|
7111
|
+
if (existsSync14(installDir)) removePathRobust(installDir);
|
|
6588
7112
|
} catch {
|
|
6589
7113
|
}
|
|
6590
7114
|
if (error instanceof AuxiliaryError) throw error;
|
|
@@ -6599,7 +7123,7 @@ async function installMcpServerFromGit(options) {
|
|
|
6599
7123
|
}
|
|
6600
7124
|
|
|
6601
7125
|
// src/host/mcp-connectors/io.ts
|
|
6602
|
-
function
|
|
7126
|
+
function snapshotOf2(host) {
|
|
6603
7127
|
return {
|
|
6604
7128
|
connectors: host.store.load().connectors,
|
|
6605
7129
|
bridgeAvailable: host.runtime.bridgeAvailable,
|
|
@@ -6614,12 +7138,12 @@ function findByServerName(connectors, serverName, exceptId) {
|
|
|
6614
7138
|
async function persistAndSync(host, connectors) {
|
|
6615
7139
|
host.store.save(connectors);
|
|
6616
7140
|
await host.runtime.sync();
|
|
6617
|
-
return
|
|
7141
|
+
return snapshotOf2(host);
|
|
6618
7142
|
}
|
|
6619
7143
|
async function listMcpConnectorsNow(host) {
|
|
6620
7144
|
await host.runtime.ensureBridge();
|
|
6621
7145
|
await host.runtime.sync();
|
|
6622
|
-
return
|
|
7146
|
+
return snapshotOf2(host);
|
|
6623
7147
|
}
|
|
6624
7148
|
async function upsertMcpConnectorNow(host, request) {
|
|
6625
7149
|
const serverName = assertServerName(request.serverName);
|
|
@@ -6682,7 +7206,7 @@ async function uninstallMcpConnectorNow(host, request) {
|
|
|
6682
7206
|
}
|
|
6683
7207
|
const next = doc.connectors.filter((entry) => entry.id !== request.id);
|
|
6684
7208
|
const installDir = mcpServerInstallDir(host.store.rootDir, request.id);
|
|
6685
|
-
if (
|
|
7209
|
+
if (existsSync15(installDir)) {
|
|
6686
7210
|
try {
|
|
6687
7211
|
removePathRobust(installDir);
|
|
6688
7212
|
} catch (error) {
|
|
@@ -6793,7 +7317,7 @@ async function importMcpJsonNow(host, request) {
|
|
|
6793
7317
|
return {
|
|
6794
7318
|
imported,
|
|
6795
7319
|
skipped,
|
|
6796
|
-
snapshot:
|
|
7320
|
+
snapshot: snapshotOf2(host)
|
|
6797
7321
|
};
|
|
6798
7322
|
}
|
|
6799
7323
|
function listMcpConnectorToolsNow(host, request) {
|
|
@@ -6814,7 +7338,7 @@ function listMcpConnectorToolsNow(host, request) {
|
|
|
6814
7338
|
}
|
|
6815
7339
|
|
|
6816
7340
|
// src/host/mcp-connectors/store.ts
|
|
6817
|
-
import { mkdirSync as mkdirSync8, readFileSync as readFileSync8, renameSync as
|
|
7341
|
+
import { mkdirSync as mkdirSync8, readFileSync as readFileSync8, renameSync as renameSync7, writeFileSync as writeFileSync4 } from "node:fs";
|
|
6818
7342
|
import { dirname as dirname10 } from "node:path";
|
|
6819
7343
|
|
|
6820
7344
|
// src/host/mcp-connectors/types.ts
|
|
@@ -6920,7 +7444,7 @@ function createMcpConnectorsStore(rootDir) {
|
|
|
6920
7444
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
6921
7445
|
writeFileSync4(tmp, `${JSON.stringify(doc, null, 2)}
|
|
6922
7446
|
`, "utf8");
|
|
6923
|
-
|
|
7447
|
+
renameSync7(tmp, file);
|
|
6924
7448
|
return doc;
|
|
6925
7449
|
}
|
|
6926
7450
|
};
|
|
@@ -7602,7 +8126,7 @@ var SoftPauseGate = class {
|
|
|
7602
8126
|
this.clear(sessionId);
|
|
7603
8127
|
return;
|
|
7604
8128
|
}
|
|
7605
|
-
await new Promise((
|
|
8129
|
+
await new Promise((resolve16) => {
|
|
7606
8130
|
let settled = false;
|
|
7607
8131
|
const settle = () => {
|
|
7608
8132
|
if (settled) return;
|
|
@@ -7613,7 +8137,7 @@ var SoftPauseGate = class {
|
|
|
7613
8137
|
bucket2.delete(waiter);
|
|
7614
8138
|
if (bucket2.size === 0) this.waiters.delete(sessionId);
|
|
7615
8139
|
}
|
|
7616
|
-
|
|
8140
|
+
resolve16();
|
|
7617
8141
|
};
|
|
7618
8142
|
const onAbort = () => {
|
|
7619
8143
|
this.engaged.delete(sessionId);
|
|
@@ -8827,7 +9351,7 @@ function mergeUsageCalls(stored, history) {
|
|
|
8827
9351
|
// src/host/usage/ledger.ts
|
|
8828
9352
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
8829
9353
|
import { chmod as chmod4, mkdir as mkdir5, readFile as readFile5, rename as rename4, unlink as unlink5, writeFile as writeFile4 } from "node:fs/promises";
|
|
8830
|
-
import { basename as
|
|
9354
|
+
import { basename as basename14, join as join27 } from "node:path";
|
|
8831
9355
|
import { z as z3 } from "zod";
|
|
8832
9356
|
var callSchema = z3.object({
|
|
8833
9357
|
at: z3.number().int().nonnegative(),
|
|
@@ -8857,7 +9381,7 @@ async function removeIfPresent5(path) {
|
|
|
8857
9381
|
}
|
|
8858
9382
|
}
|
|
8859
9383
|
async function writeAtomic4(path, value) {
|
|
8860
|
-
const temporary =
|
|
9384
|
+
const temporary = join27(join27(path, ".."), `.${basename14(path)}.${randomUUID6()}.tmp`);
|
|
8861
9385
|
try {
|
|
8862
9386
|
await writeFile4(temporary, JSON.stringify(value), { encoding: "utf8", mode: 384, flag: "wx" });
|
|
8863
9387
|
await rename4(temporary, path);
|
|
@@ -8871,7 +9395,7 @@ var UsageLedger = class {
|
|
|
8871
9395
|
}) {
|
|
8872
9396
|
this.root = root;
|
|
8873
9397
|
this.warn = warn;
|
|
8874
|
-
this.file =
|
|
9398
|
+
this.file = join27(root, "ledger.json");
|
|
8875
9399
|
}
|
|
8876
9400
|
root;
|
|
8877
9401
|
warn;
|
|
@@ -9394,6 +9918,23 @@ var softPauseSetRequestCodec = codec(
|
|
|
9394
9918
|
softPauseSetRequestSchema
|
|
9395
9919
|
);
|
|
9396
9920
|
var softPauseStateCodec = codec("dsh-agent-enhancer#SoftPauseState", softPauseStateSchema);
|
|
9921
|
+
var showOsNotificationRequestSchema = z4.strictObject({
|
|
9922
|
+
title: z4.string().min(1).max(120),
|
|
9923
|
+
body: z4.string().min(1).max(240),
|
|
9924
|
+
tag: z4.string().max(120).optional()
|
|
9925
|
+
});
|
|
9926
|
+
var showOsNotificationResultSchema = z4.strictObject({
|
|
9927
|
+
shown: z4.boolean(),
|
|
9928
|
+
channel: z4.enum(["electron", "windows", "none"])
|
|
9929
|
+
});
|
|
9930
|
+
var showOsNotificationRequestCodec = codec(
|
|
9931
|
+
"dsh-agent-enhancer#ShowOsNotificationRequest",
|
|
9932
|
+
showOsNotificationRequestSchema
|
|
9933
|
+
);
|
|
9934
|
+
var showOsNotificationResultCodec = codec(
|
|
9935
|
+
"dsh-agent-enhancer#ShowOsNotificationResult",
|
|
9936
|
+
showOsNotificationResultSchema
|
|
9937
|
+
);
|
|
9397
9938
|
var instructionScopeSchema = z4.enum(["global", "shared", "project"]);
|
|
9398
9939
|
var instructionFileEntrySchema = z4.strictObject({
|
|
9399
9940
|
id: z4.string().min(1),
|
|
@@ -9420,7 +9961,8 @@ var skillCatalogEntrySchema = z4.strictObject({
|
|
|
9420
9961
|
updateCheckFailed: z4.boolean()
|
|
9421
9962
|
});
|
|
9422
9963
|
var listInstructionsSkillsRequestSchema = z4.strictObject({
|
|
9423
|
-
sessionId: sessionIdSchema3
|
|
9964
|
+
sessionId: sessionIdSchema3,
|
|
9965
|
+
checkUpdates: z4.boolean().optional()
|
|
9424
9966
|
});
|
|
9425
9967
|
var instructionsSkillsSnapshotSchema = z4.strictObject({
|
|
9426
9968
|
sessionId: sessionIdSchema3,
|
|
@@ -9471,7 +10013,7 @@ var createWorkspaceSkillResultCodec = codec(
|
|
|
9471
10013
|
"dsh-agent-enhancer#CreateWorkspaceSkillResult",
|
|
9472
10014
|
createWorkspaceSkillResultSchema
|
|
9473
10015
|
);
|
|
9474
|
-
var skillInstallTargetSchema = z4.enum(["user", "project"]);
|
|
10016
|
+
var skillInstallTargetSchema = z4.enum(["user", "user-dsh", "project", "project-dsh"]);
|
|
9475
10017
|
var skillInstallModeSchema = z4.enum(["link", "copy"]);
|
|
9476
10018
|
var installedSkillRefSchema = z4.strictObject({
|
|
9477
10019
|
name: z4.string().min(1),
|
|
@@ -9486,6 +10028,7 @@ var installSkillFromGitRequestSchema = z4.strictObject({
|
|
|
9486
10028
|
});
|
|
9487
10029
|
var installSkillFromGitResultSchema = z4.strictObject({
|
|
9488
10030
|
installed: z4.array(installedSkillRefSchema),
|
|
10031
|
+
skippedBusy: z4.array(z4.string().min(1)).default([]),
|
|
9489
10032
|
snapshot: instructionsSkillsSnapshotSchema
|
|
9490
10033
|
});
|
|
9491
10034
|
var installSkillFromZipRequestSchema = z4.strictObject({
|
|
@@ -9528,6 +10071,17 @@ var readSkillDocumentResultSchema = z4.strictObject({
|
|
|
9528
10071
|
text: z4.string(),
|
|
9529
10072
|
bytes: z4.number().int().nonnegative()
|
|
9530
10073
|
});
|
|
10074
|
+
var getSkillInstallProgressRequestSchema = z4.strictObject({
|
|
10075
|
+
sessionId: sessionIdSchema3
|
|
10076
|
+
});
|
|
10077
|
+
var getSkillInstallProgressResultSchema = z4.strictObject({
|
|
10078
|
+
sessionId: z4.string(),
|
|
10079
|
+
stage: z4.enum(SKILL_INSTALL_STAGES),
|
|
10080
|
+
detail: z4.string().nullable(),
|
|
10081
|
+
bytesReceived: z4.number().nonnegative().nullable(),
|
|
10082
|
+
bytesTotal: z4.number().positive().nullable(),
|
|
10083
|
+
startedAt: z4.number().nonnegative().nullable()
|
|
10084
|
+
});
|
|
9531
10085
|
var installSkillFromGitRequestCodec = codec(
|
|
9532
10086
|
"dsh-agent-enhancer#InstallSkillFromGitRequest",
|
|
9533
10087
|
installSkillFromGitRequestSchema
|
|
@@ -9568,6 +10122,14 @@ var readSkillDocumentResultCodec = codec(
|
|
|
9568
10122
|
"dsh-agent-enhancer#ReadSkillDocumentResult",
|
|
9569
10123
|
readSkillDocumentResultSchema
|
|
9570
10124
|
);
|
|
10125
|
+
var getSkillInstallProgressRequestCodec = codec(
|
|
10126
|
+
"dsh-agent-enhancer#GetSkillInstallProgressRequest",
|
|
10127
|
+
getSkillInstallProgressRequestSchema
|
|
10128
|
+
);
|
|
10129
|
+
var getSkillInstallProgressResultCodec = codec(
|
|
10130
|
+
"dsh-agent-enhancer#GetSkillInstallProgressResult",
|
|
10131
|
+
getSkillInstallProgressResultSchema
|
|
10132
|
+
);
|
|
9571
10133
|
var mcpInstallChannelSchema = z4.enum(["manual", "npx", "github", "mcpJson"]);
|
|
9572
10134
|
var mcpStdioTransportSchema = z4.strictObject({
|
|
9573
10135
|
transport: z4.literal("stdio"),
|
|
@@ -9953,6 +10515,18 @@ var remoteInfo = createTypertRemoteInfo({
|
|
|
9953
10515
|
}],
|
|
9954
10516
|
result: softPauseStateCodec
|
|
9955
10517
|
},
|
|
10518
|
+
"agentEnhancer/showOsNotification": {
|
|
10519
|
+
service: "agentEnhancer",
|
|
10520
|
+
implementation: "showOsNotification",
|
|
10521
|
+
invocation: { kind: "direct" },
|
|
10522
|
+
parameters: [{
|
|
10523
|
+
name: "request",
|
|
10524
|
+
source: "json",
|
|
10525
|
+
codec: showOsNotificationRequestCodec,
|
|
10526
|
+
strictCodec: showOsNotificationRequestCodec
|
|
10527
|
+
}],
|
|
10528
|
+
result: showOsNotificationResultCodec
|
|
10529
|
+
},
|
|
9956
10530
|
"agentEnhancer/listInstructionsSkills": {
|
|
9957
10531
|
service: "agentEnhancer",
|
|
9958
10532
|
implementation: "listInstructionsSkills",
|
|
@@ -10057,6 +10631,19 @@ var remoteInfo = createTypertRemoteInfo({
|
|
|
10057
10631
|
cancellation: { parameter: "signal" },
|
|
10058
10632
|
result: readSkillDocumentResultCodec
|
|
10059
10633
|
},
|
|
10634
|
+
"agentEnhancer/getSkillInstallProgress": {
|
|
10635
|
+
service: "agentEnhancer",
|
|
10636
|
+
implementation: "getSkillInstallProgress",
|
|
10637
|
+
invocation: { kind: "direct" },
|
|
10638
|
+
parameters: [{
|
|
10639
|
+
name: "request",
|
|
10640
|
+
source: "json",
|
|
10641
|
+
codec: getSkillInstallProgressRequestCodec,
|
|
10642
|
+
strictCodec: getSkillInstallProgressRequestCodec
|
|
10643
|
+
}],
|
|
10644
|
+
cancellation: { parameter: "signal" },
|
|
10645
|
+
result: getSkillInstallProgressResultCodec
|
|
10646
|
+
},
|
|
10060
10647
|
"agentEnhancer/listMcpConnectors": {
|
|
10061
10648
|
service: "agentEnhancer",
|
|
10062
10649
|
implementation: "listMcpConnectors",
|
|
@@ -10341,9 +10928,110 @@ var checkpointRemoteInfo = createTypertRemoteInfo({
|
|
|
10341
10928
|
}
|
|
10342
10929
|
}, z4);
|
|
10343
10930
|
|
|
10931
|
+
// src/host/run-alerts/notify.ts
|
|
10932
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
10933
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
10934
|
+
import { promisify as promisify5 } from "node:util";
|
|
10935
|
+
var execFileAsync5 = promisify5(execFile5);
|
|
10936
|
+
var nodeRequire2 = createRequire2(import.meta.url);
|
|
10937
|
+
var DESKTOP_WINDOWS_APP_USER_MODEL_ID = "electron.app.DeepSeek Harness";
|
|
10938
|
+
function loadElectron() {
|
|
10939
|
+
try {
|
|
10940
|
+
return nodeRequire2("electron");
|
|
10941
|
+
} catch {
|
|
10942
|
+
return void 0;
|
|
10943
|
+
}
|
|
10944
|
+
}
|
|
10945
|
+
function resolveWindowsAppId(electron = loadElectron()) {
|
|
10946
|
+
const fromEnv = process.env.DSH_TOAST_APP_ID?.trim();
|
|
10947
|
+
if (fromEnv) return fromEnv;
|
|
10948
|
+
try {
|
|
10949
|
+
const id = electron?.app?.getAppUserModelId?.();
|
|
10950
|
+
if (typeof id === "string" && id.trim() !== "") return id.trim();
|
|
10951
|
+
} catch {
|
|
10952
|
+
}
|
|
10953
|
+
try {
|
|
10954
|
+
const name2 = electron?.app?.getName?.() ?? electron?.app?.name;
|
|
10955
|
+
if (typeof name2 === "string" && name2.trim() !== "") {
|
|
10956
|
+
return `electron.app.${name2.trim()}`;
|
|
10957
|
+
}
|
|
10958
|
+
} catch {
|
|
10959
|
+
}
|
|
10960
|
+
return DESKTOP_WINDOWS_APP_USER_MODEL_ID;
|
|
10961
|
+
}
|
|
10962
|
+
function showViaElectron(input, electron = loadElectron()) {
|
|
10963
|
+
try {
|
|
10964
|
+
const NotificationCtor = electron?.Notification;
|
|
10965
|
+
if (NotificationCtor === void 0) return false;
|
|
10966
|
+
if (typeof NotificationCtor.isSupported === "function" && !NotificationCtor.isSupported()) {
|
|
10967
|
+
return false;
|
|
10968
|
+
}
|
|
10969
|
+
const note = new NotificationCtor({
|
|
10970
|
+
title: input.title,
|
|
10971
|
+
body: input.body,
|
|
10972
|
+
silent: false
|
|
10973
|
+
});
|
|
10974
|
+
note.show();
|
|
10975
|
+
return true;
|
|
10976
|
+
} catch {
|
|
10977
|
+
return false;
|
|
10978
|
+
}
|
|
10979
|
+
}
|
|
10980
|
+
function escapeXml(value) {
|
|
10981
|
+
return value.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">").replace(/"/gu, """).replace(/'/gu, "'");
|
|
10982
|
+
}
|
|
10983
|
+
function escapePowerShellSingle(value) {
|
|
10984
|
+
return value.replace(/'/gu, "''");
|
|
10985
|
+
}
|
|
10986
|
+
async function showViaWindowsToast(input, appId) {
|
|
10987
|
+
if (process.platform !== "win32") return false;
|
|
10988
|
+
const title = escapeXml(input.title.slice(0, 120));
|
|
10989
|
+
const body = escapeXml(input.body.slice(0, 240));
|
|
10990
|
+
const xml = escapePowerShellSingle(
|
|
10991
|
+
`<toast><visual><binding template="ToastGeneric"><text>${title}</text><text>${body}</text></binding></visual></toast>`
|
|
10992
|
+
);
|
|
10993
|
+
const script = [
|
|
10994
|
+
"$ErrorActionPreference = 'Stop'",
|
|
10995
|
+
"[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null",
|
|
10996
|
+
"[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null",
|
|
10997
|
+
`$xml = '${xml}'`,
|
|
10998
|
+
"$doc = New-Object Windows.Data.Xml.Dom.XmlDocument",
|
|
10999
|
+
"$doc.LoadXml($xml)",
|
|
11000
|
+
`$appId = '${escapePowerShellSingle(appId)}'`,
|
|
11001
|
+
"$toast = [Windows.UI.Notifications.ToastNotification]::new($doc)",
|
|
11002
|
+
"[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($appId).Show($toast)"
|
|
11003
|
+
].join("; ");
|
|
11004
|
+
try {
|
|
11005
|
+
await execFileAsync5("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
|
|
11006
|
+
windowsHide: true,
|
|
11007
|
+
timeout: 8e3,
|
|
11008
|
+
env: process.env
|
|
11009
|
+
});
|
|
11010
|
+
return true;
|
|
11011
|
+
} catch {
|
|
11012
|
+
return false;
|
|
11013
|
+
}
|
|
11014
|
+
}
|
|
11015
|
+
async function showOsNotificationNow(input) {
|
|
11016
|
+
const title = input.title.trim();
|
|
11017
|
+
const body = input.body.trim();
|
|
11018
|
+
if (title === "" || body === "") return { shown: false, channel: "none" };
|
|
11019
|
+
const payload = {
|
|
11020
|
+
title: title.slice(0, 120),
|
|
11021
|
+
body: body.slice(0, 240),
|
|
11022
|
+
...input.tag === void 0 ? {} : { tag: input.tag }
|
|
11023
|
+
};
|
|
11024
|
+
const electron = loadElectron();
|
|
11025
|
+
if (showViaElectron(payload, electron)) return { shown: true, channel: "electron" };
|
|
11026
|
+
if (await showViaWindowsToast(payload, resolveWindowsAppId(electron))) {
|
|
11027
|
+
return { shown: true, channel: "windows" };
|
|
11028
|
+
}
|
|
11029
|
+
return { shown: false, channel: "none" };
|
|
11030
|
+
}
|
|
11031
|
+
|
|
10344
11032
|
// src/host/update/check.ts
|
|
10345
|
-
import { homedir as
|
|
10346
|
-
import { join as
|
|
11033
|
+
import { homedir as homedir4 } from "node:os";
|
|
11034
|
+
import { join as join29 } from "node:path";
|
|
10347
11035
|
|
|
10348
11036
|
// src/host/update/cli.ts
|
|
10349
11037
|
import { spawn as nodeSpawn } from "node:child_process";
|
|
@@ -10370,14 +11058,14 @@ function resolveCanAutoApply(input) {
|
|
|
10370
11058
|
return input.installKind === "npm" && input.dshAvailable;
|
|
10371
11059
|
}
|
|
10372
11060
|
function waitForExit(child, timeoutMs) {
|
|
10373
|
-
return new Promise((
|
|
11061
|
+
return new Promise((resolve16) => {
|
|
10374
11062
|
let settled = false;
|
|
10375
11063
|
const chunks = [];
|
|
10376
11064
|
const finish = (ok, detail) => {
|
|
10377
11065
|
if (settled) return;
|
|
10378
11066
|
settled = true;
|
|
10379
11067
|
clearTimeout(timer);
|
|
10380
|
-
|
|
11068
|
+
resolve16({ ok, detail });
|
|
10381
11069
|
};
|
|
10382
11070
|
const timer = setTimeout(() => {
|
|
10383
11071
|
child.kill();
|
|
@@ -10413,12 +11101,12 @@ async function runPluginAdd(latest, spawnFn = defaultSpawn) {
|
|
|
10413
11101
|
}
|
|
10414
11102
|
|
|
10415
11103
|
// src/host/update/install-kind.ts
|
|
10416
|
-
import { lstatSync as
|
|
10417
|
-
import { join as
|
|
11104
|
+
import { lstatSync as lstatSync5 } from "node:fs";
|
|
11105
|
+
import { join as join28 } from "node:path";
|
|
10418
11106
|
function detectInstallKind(profileDir) {
|
|
10419
|
-
const pkgPath =
|
|
11107
|
+
const pkgPath = join28(profileDir, "node_modules", PACKAGE_NAME);
|
|
10420
11108
|
try {
|
|
10421
|
-
const stat =
|
|
11109
|
+
const stat = lstatSync5(pkgPath);
|
|
10422
11110
|
if (stat.isSymbolicLink()) return "link";
|
|
10423
11111
|
if (stat.isDirectory()) return "npm";
|
|
10424
11112
|
return "unknown";
|
|
@@ -10546,9 +11234,9 @@ function isNewerVersion(latest, current) {
|
|
|
10546
11234
|
}
|
|
10547
11235
|
|
|
10548
11236
|
// src/host/update/check.ts
|
|
10549
|
-
function resolveDesktopProfileDir(env = process.env, home =
|
|
10550
|
-
const dshHome2 = env.DSH_HOME ??
|
|
10551
|
-
return
|
|
11237
|
+
function resolveDesktopProfileDir(env = process.env, home = homedir4()) {
|
|
11238
|
+
const dshHome2 = env.DSH_HOME ?? join29(home, ".dsh");
|
|
11239
|
+
return join29(dshHome2, "profiles", "desktop");
|
|
10552
11240
|
}
|
|
10553
11241
|
async function checkPluginUpdate(deps) {
|
|
10554
11242
|
const latest = await deps.fetchLatest();
|
|
@@ -10634,6 +11322,9 @@ var Config = z5.object({
|
|
|
10634
11322
|
sessionDeleteEnabled: z5.boolean().default(true).volatile(),
|
|
10635
11323
|
fileEditEnabled: z5.boolean().default(true).volatile(),
|
|
10636
11324
|
softPauseEnabled: z5.boolean().default(true).volatile(),
|
|
11325
|
+
runAlertsEnabled: z5.boolean().default(true).volatile(),
|
|
11326
|
+
/** Coerced via resolveRunAlertsLevel in readSettings (`hidden` | `unfocused` | `always`). */
|
|
11327
|
+
runAlertsLevel: z5.string().default("unfocused").volatile(),
|
|
10637
11328
|
instructionsSkillsEnabled: z5.boolean().default(true).volatile(),
|
|
10638
11329
|
mcpConnectorsEnabled: z5.boolean().default(true).volatile(),
|
|
10639
11330
|
// Empty provider/model = follow the current Desktop session model.
|
|
@@ -10680,7 +11371,7 @@ var AgentEnhancerService = class extends TypertRemoteService {
|
|
|
10680
11371
|
};
|
|
10681
11372
|
}
|
|
10682
11373
|
}, sessionCleanup = new SessionCleanupRegistry(), extraFolders = createExtraFoldersStore(
|
|
10683
|
-
|
|
11374
|
+
join30(homedir5(), ".dsh", "profiles", "desktop", "plugin-data", PACKAGE_NAME, "extra-folders")
|
|
10684
11375
|
), softPause = new SoftPauseGate(), softPauseEnabled = () => true, installLedgerRoot = void 0, mcpHost = null) {
|
|
10685
11376
|
super(ctx, "agentEnhancer");
|
|
10686
11377
|
this.models = models;
|
|
@@ -11003,6 +11694,12 @@ var AgentEnhancerService = class extends TypertRemoteService {
|
|
|
11003
11694
|
throw instructionsSkillsRemoteError(error);
|
|
11004
11695
|
}
|
|
11005
11696
|
}
|
|
11697
|
+
/** Poll GitHub skill install/update stage while installSkillFromGit / updateSkillFromGit runs. */
|
|
11698
|
+
async getSkillInstallProgress(request, signal) {
|
|
11699
|
+
this.assertOwner();
|
|
11700
|
+
signal.throwIfAborted();
|
|
11701
|
+
return getSkillInstallProgressSnapshot(String(request.sessionId));
|
|
11702
|
+
}
|
|
11006
11703
|
/** Remove a skill from a managed install root (user/project skills). */
|
|
11007
11704
|
async uninstallSkill(request, signal) {
|
|
11008
11705
|
this.assertOwner();
|
|
@@ -11170,6 +11867,11 @@ var AgentEnhancerService = class extends TypertRemoteService {
|
|
|
11170
11867
|
else this.softPause.release(request.sessionId);
|
|
11171
11868
|
return { sessionId: request.sessionId, engaged: this.softPause.isEngaged(request.sessionId) };
|
|
11172
11869
|
}
|
|
11870
|
+
/** Desktop OS notification for run alerts (Electron / Windows Action Center). */
|
|
11871
|
+
async showOsNotification(request) {
|
|
11872
|
+
this.assertOwner();
|
|
11873
|
+
return await showOsNotificationNow(request);
|
|
11874
|
+
}
|
|
11173
11875
|
async applyUpdate() {
|
|
11174
11876
|
this.assertOwner();
|
|
11175
11877
|
return applyPluginUpdateForHost({
|
|
@@ -11182,16 +11884,16 @@ var AgentEnhancerService = class extends TypertRemoteService {
|
|
|
11182
11884
|
}
|
|
11183
11885
|
};
|
|
11184
11886
|
function resolveCheckpointRoot(dshHome2) {
|
|
11185
|
-
const base =
|
|
11186
|
-
const nextPkg =
|
|
11187
|
-
const next =
|
|
11188
|
-
const prev =
|
|
11189
|
-
if (!
|
|
11887
|
+
const base = join30(dshHome2, "profiles", "desktop", "plugin-data");
|
|
11888
|
+
const nextPkg = join30(base, PACKAGE_NAME);
|
|
11889
|
+
const next = join30(nextPkg, "checkpoint");
|
|
11890
|
+
const prev = join30(base, LEGACY_PACKAGE_NAME, "checkpoint");
|
|
11891
|
+
if (!existsSync16(next) && existsSync16(prev)) {
|
|
11190
11892
|
mkdirSync9(nextPkg, { recursive: true });
|
|
11191
|
-
|
|
11192
|
-
const prevPkg =
|
|
11893
|
+
renameSync8(prev, next);
|
|
11894
|
+
const prevPkg = join30(base, LEGACY_PACKAGE_NAME);
|
|
11193
11895
|
try {
|
|
11194
|
-
if (
|
|
11896
|
+
if (existsSync16(prevPkg) && readdirSync7(prevPkg).length === 0) rmdirSync(prevPkg);
|
|
11195
11897
|
} catch {
|
|
11196
11898
|
}
|
|
11197
11899
|
}
|
|
@@ -11259,6 +11961,8 @@ function readSettings(config) {
|
|
|
11259
11961
|
sessionDeleteEnabled: config.sessionDeleteEnabled.get(),
|
|
11260
11962
|
fileEditEnabled: config.fileEditEnabled.get(),
|
|
11261
11963
|
softPauseEnabled: config.softPauseEnabled.get(),
|
|
11964
|
+
runAlertsEnabled: config.runAlertsEnabled.get(),
|
|
11965
|
+
runAlertsLevel: resolveRunAlertsLevel(config.runAlertsLevel.get()),
|
|
11262
11966
|
instructionsSkillsEnabled: config.instructionsSkillsEnabled.get(),
|
|
11263
11967
|
mcpConnectorsEnabled: config.mcpConnectorsEnabled.get(),
|
|
11264
11968
|
optimizeProvider: config.optimizeProvider.get(),
|
|
@@ -11289,9 +11993,9 @@ function apply(ctx, config) {
|
|
|
11289
11993
|
const settings = () => readSettings(config);
|
|
11290
11994
|
const models = new AuxiliaryModels(ctx, settings);
|
|
11291
11995
|
installAutoSessionRoute(ctx, { settings });
|
|
11292
|
-
const storageRoot = resolveCheckpointRoot(process.env.DSH_HOME ??
|
|
11293
|
-
const pluginDataPackageRoot =
|
|
11294
|
-
const usage = new UsageLedger(
|
|
11996
|
+
const storageRoot = resolveCheckpointRoot(process.env.DSH_HOME ?? join30(homedir5(), ".dsh"));
|
|
11997
|
+
const pluginDataPackageRoot = join30(storageRoot, "..");
|
|
11998
|
+
const usage = new UsageLedger(join30(storageRoot, "..", "usage"), (message) => {
|
|
11295
11999
|
ctx.logger.warn(message);
|
|
11296
12000
|
});
|
|
11297
12001
|
const balancesFacade = (() => {
|
|
@@ -11321,12 +12025,12 @@ function apply(ctx, config) {
|
|
|
11321
12025
|
})();
|
|
11322
12026
|
installUsageObserver(ctx, usage);
|
|
11323
12027
|
const store = new CheckpointStore(storageRoot);
|
|
11324
|
-
const cutStore = new SessionCutStore(
|
|
12028
|
+
const cutStore = new SessionCutStore(join30(storageRoot, "cuts"));
|
|
11325
12029
|
const cutCache = /* @__PURE__ */ new Map();
|
|
11326
12030
|
const sessionCleanup = new SessionCleanupRegistry();
|
|
11327
12031
|
sessionCleanup.register(createCheckpointCleaner({ store, cutStore, storageRoot }));
|
|
11328
|
-
sessionCleanup.register(createContextExcludeCleaner(
|
|
11329
|
-
const extraFoldersStore = createExtraFoldersStore(
|
|
12032
|
+
sessionCleanup.register(createContextExcludeCleaner(join30(storageRoot, "..")));
|
|
12033
|
+
const extraFoldersStore = createExtraFoldersStore(join30(storageRoot, "..", "extra-folders"));
|
|
11330
12034
|
const softPauseGate = new SoftPauseGate();
|
|
11331
12035
|
const mcpStore = createMcpConnectorsStore(mcpConnectorsRoot(pluginDataPackageRoot));
|
|
11332
12036
|
const mcpRuntime = new McpConnectorRuntime(ctx, mcpStore);
|