@dawn0608/dsh-skill-manager 0.1.1 → 0.1.3
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.md +38 -18
- package/README.zh.md +38 -18
- package/lib/THIRD_PARTY_NOTICES.md +2588 -0
- package/lib/client.js +40349 -159
- package/lib/client.js.map +4 -4
- package/lib/index.js +18 -9
- package/lib/index.js.map +3 -3
- package/lib/install-sync.js +7693 -0
- package/lib/install-sync.js.map +7 -0
- package/lib/sync-daemon.js +8807 -0
- package/lib/sync-daemon.js.map +7 -0
- package/package.json +29 -25
package/lib/index.js
CHANGED
|
@@ -7413,7 +7413,7 @@ var require_dist = __commonJS({
|
|
|
7413
7413
|
|
|
7414
7414
|
// src/index.js
|
|
7415
7415
|
import { homedir } from "node:os";
|
|
7416
|
-
import { join as join5, resolve } from "node:path";
|
|
7416
|
+
import { join as join5, resolve as resolve2 } from "node:path";
|
|
7417
7417
|
|
|
7418
7418
|
// src/host.js
|
|
7419
7419
|
import { isAbsolute as isAbsolute2, join as join4, normalize } from "node:path";
|
|
@@ -7933,7 +7933,7 @@ function createSkillStore(home) {
|
|
|
7933
7933
|
import { constants as constants3, watchFile, unwatchFile } from "node:fs";
|
|
7934
7934
|
import { lstat as lstat2, open as open2, readdir, realpath as realpath2 } from "node:fs/promises";
|
|
7935
7935
|
import { createConnection } from "node:net";
|
|
7936
|
-
import { dirname as dirname2, join as join3 } from "node:path";
|
|
7936
|
+
import { dirname as dirname2, join as join3, resolve } from "node:path";
|
|
7937
7937
|
var syncDirectory = (home) => join3(home, "skill-manager", "shared-sync");
|
|
7938
7938
|
var syncSocket = (home) => join3(syncDirectory(home), "control.sock");
|
|
7939
7939
|
var syncStateFile = (home) => join3(syncDirectory(home), "state.json");
|
|
@@ -7990,7 +7990,7 @@ async function readSyncState(home) {
|
|
|
7990
7990
|
}
|
|
7991
7991
|
}
|
|
7992
7992
|
function requestSync(home, message) {
|
|
7993
|
-
return new Promise((
|
|
7993
|
+
return new Promise((resolve3, reject) => {
|
|
7994
7994
|
const socket = createConnection(syncSocket(home));
|
|
7995
7995
|
let data = "";
|
|
7996
7996
|
const fail = () => {
|
|
@@ -8009,7 +8009,7 @@ function requestSync(home, message) {
|
|
|
8009
8009
|
try {
|
|
8010
8010
|
const reply = JSON.parse(data);
|
|
8011
8011
|
if (!reply.ok) return reject(new ManagerError(reply.error === "conflict" ? "conflict" : "unavailable"));
|
|
8012
|
-
|
|
8012
|
+
resolve3(reply.result);
|
|
8013
8013
|
} catch {
|
|
8014
8014
|
fail();
|
|
8015
8015
|
}
|
|
@@ -8017,6 +8017,12 @@ function requestSync(home, message) {
|
|
|
8017
8017
|
socket.on("end", fail);
|
|
8018
8018
|
});
|
|
8019
8019
|
}
|
|
8020
|
+
function sharedPolicyEnabled(entry) {
|
|
8021
|
+
if (!entry) return void 0;
|
|
8022
|
+
if (typeof entry.policyEnabled === "boolean") return entry.policyEnabled;
|
|
8023
|
+
if (entry.pending && (entry.codex === false || entry.claude === "off")) return false;
|
|
8024
|
+
return entry.enabled;
|
|
8025
|
+
}
|
|
8020
8026
|
function registerSharedPolicy(skills, home, agentsHome) {
|
|
8021
8027
|
if (typeof skills.registerProvider !== "function") return () => {
|
|
8022
8028
|
};
|
|
@@ -8027,8 +8033,8 @@ function registerSharedPolicy(skills, home, agentsHome) {
|
|
|
8027
8033
|
name: "skill-manager-shared-policy",
|
|
8028
8034
|
async list() {
|
|
8029
8035
|
const state = await readSyncState(home);
|
|
8030
|
-
if (!state || !Object.values(state.entries).some((entry) => entry
|
|
8031
|
-
return [...(await sharedSkills(agentsHome)).values()].filter((skill) => state.entries[skill.path]
|
|
8036
|
+
if (!state || !Object.values(state.entries).some((entry) => sharedPolicyEnabled(entry) === false)) return [];
|
|
8037
|
+
return [...(await sharedSkills(agentsHome)).values()].filter((skill) => sharedPolicyEnabled(state.entries[skill.path]) === false).map((skill) => ({
|
|
8032
8038
|
...skill,
|
|
8033
8039
|
provider: "skill-manager-shared-policy",
|
|
8034
8040
|
source: "user-agents",
|
|
@@ -8107,7 +8113,7 @@ function catalogRow(skill, provenance, shared) {
|
|
|
8107
8113
|
description: skill.description,
|
|
8108
8114
|
group: SOURCES.get(skill.source) ?? "local",
|
|
8109
8115
|
source: SOURCES.has(skill.source) ? skill.source : "other",
|
|
8110
|
-
enabled: skill.source === "user-agents" && typeof shared?.[skill.path]
|
|
8116
|
+
enabled: skill.source === "user-agents" && typeof sharedPolicyEnabled(shared?.[skill.path]) === "boolean" ? sharedPolicyEnabled(shared[skill.path]) : null,
|
|
8111
8117
|
shadowed: false,
|
|
8112
8118
|
...origin && { origin }
|
|
8113
8119
|
};
|
|
@@ -8175,11 +8181,14 @@ function createSkillManager({ home, agentsHome, skills, workspaceRegistry, agent
|
|
|
8175
8181
|
rows.push(...[...byName.values()].map((skill) => catalogRow(skill, provenance, sync?.entries)));
|
|
8176
8182
|
rows.sort((left, right) => left.name.localeCompare(right.name) || Number(right.group === "imported") - Number(left.group === "imported"));
|
|
8177
8183
|
const syncError = sync?.error ?? Object.values(sync?.entries ?? {}).find((entry) => entry.error)?.error;
|
|
8184
|
+
const stopped = sync && !sync.error && (!Number.isFinite(Date.parse(sync.health?.lastAttemptAt)) || Date.now() - Date.parse(sync.health.lastAttemptAt) > 15e3);
|
|
8185
|
+
const healthError = stopped ? "sharedStopped" : sync?.health?.status === "unavailable" ? "sharedUnavailable" : null;
|
|
8178
8186
|
return {
|
|
8187
|
+
...sync?.health && { syncHealth: sync.health },
|
|
8179
8188
|
skills: rows,
|
|
8180
8189
|
workspaces,
|
|
8181
8190
|
complete: catalog.complete && managed.complete,
|
|
8182
|
-
...syncError && { syncError: syncError === "conflict" ? "sharedConflict" : "sharedUnavailable" }
|
|
8191
|
+
...(healthError || syncError) && { syncError: healthError ?? (syncError === "conflict" ? "sharedConflict" : "sharedUnavailable") }
|
|
8183
8192
|
};
|
|
8184
8193
|
}
|
|
8185
8194
|
async function detail(id, options) {
|
|
@@ -8313,7 +8322,7 @@ function createFetchHandler(manager) {
|
|
|
8313
8322
|
// src/index.js
|
|
8314
8323
|
var inject = ["agentPresets", "connection", "skills", "workspaceRegistry"];
|
|
8315
8324
|
function resolveHome(configured, fallback) {
|
|
8316
|
-
return configured?.trim() ?
|
|
8325
|
+
return configured?.trim() ? resolve2(
|
|
8317
8326
|
configured === "~" ? homedir() : /^~[/\\]/.test(configured) ? join5(homedir(), configured.slice(2)) : configured
|
|
8318
8327
|
) : join5(homedir(), fallback);
|
|
8319
8328
|
}
|