@agentsky/sky 3.48.1 → 3.48.2

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.
@@ -0,0 +1,317 @@
1
+ import {
2
+ detectLocalAgents
3
+ } from "./chunk-2H4W5ZKZ.js";
4
+ import {
5
+ SKILL_NAME
6
+ } from "./chunk-PGX3AGCZ.js";
7
+
8
+ // src/mcp-register.ts
9
+ import { existsSync, readFileSync, writeFileSync } from "fs";
10
+ import { spawnSync } from "child_process";
11
+ import { homedir } from "os";
12
+ import { join } from "path";
13
+ import { parse as parseToml } from "smol-toml";
14
+ import { isMap, parseDocument } from "yaml";
15
+
16
+ // ../../packages/spec/src/mcp-tool-list.ts
17
+ var MCP_TOOL_LIST_PARAM = "tools";
18
+ function mcpUrlWithToolList(mcpUrl, list) {
19
+ const url = new URL(mcpUrl);
20
+ if (list === "short") url.searchParams.set(MCP_TOOL_LIST_PARAM, "short");
21
+ else url.searchParams.delete(MCP_TOOL_LIST_PARAM);
22
+ return url.toString();
23
+ }
24
+ function mcpToolListOf(mcpUrl) {
25
+ const value = (typeof mcpUrl === "string" ? new URL(mcpUrl) : mcpUrl).searchParams.get(MCP_TOOL_LIST_PARAM);
26
+ if (value === null) return "every";
27
+ return value === "short" || value === "every" ? value : null;
28
+ }
29
+
30
+ // src/mcp-register.ts
31
+ var MCP_SERVER_NAME = SKILL_NAME;
32
+ function detectHermes(env = process.env, home = homedir()) {
33
+ const root = env.HERMES_HOME || join(home, ".hermes");
34
+ return existsSync(root) ? { id: "hermes", name: "Hermes", root } : null;
35
+ }
36
+ function claudeAppRoot(env = process.env, home = homedir(), platform = process.platform) {
37
+ if (platform === "darwin") return join(home, "Library", "Application Support", "Claude");
38
+ if (platform === "win32") return join(env.APPDATA || join(home, "AppData", "Roaming"), "Claude");
39
+ return join(env.XDG_CONFIG_HOME || join(home, ".config"), "Claude");
40
+ }
41
+ function detectClaudeApp(env = process.env, home = homedir(), platform = process.platform) {
42
+ const root = claudeAppRoot(env, home, platform);
43
+ return existsSync(root) ? { id: "claude_app", name: "Claude app", root } : null;
44
+ }
45
+ function detectMcpClients(env = process.env, home = homedir(), platform = process.platform) {
46
+ const hermes = detectHermes(env, home);
47
+ const claudeApp = detectClaudeApp(env, home, platform);
48
+ return [...detectLocalAgents(env, home), ...hermes ? [hermes] : [], ...claudeApp ? [claudeApp] : []];
49
+ }
50
+ function systemCommandRunner() {
51
+ return {
52
+ has: (command) => spawnSync(command, ["--version"], { stdio: "ignore" }).status === 0,
53
+ run: (command, args) => {
54
+ const result = spawnSync(command, args, { encoding: "utf8" });
55
+ return { status: result.status, stderr: result.stderr ?? "", stdout: result.stdout ?? "" };
56
+ }
57
+ };
58
+ }
59
+ function mcpUrlFor(apiBase, list = "every") {
60
+ return mcpUrlWithToolList(`${apiBase.replace(/\/$/, "")}/mcp`, list);
61
+ }
62
+ function mcpCommands(agent, opts) {
63
+ if (agent === "grok") {
64
+ return {
65
+ command: "grok",
66
+ remove: ["mcp", "remove", MCP_SERVER_NAME],
67
+ add: ["mcp", "add", "--scope", "user", "--transport", "http", "--header", `Authorization: Bearer ${opts.token}`, MCP_SERVER_NAME, opts.mcpUrl]
68
+ };
69
+ }
70
+ return null;
71
+ }
72
+ var NO_TOOLS = "this sign-in gets no AgentSky tools (a workspace's own key has none); sign in as yourself with `sky auth login` and run setup again";
73
+ function redact(text, token) {
74
+ return text.split(token).join(`${token.slice(0, 10)}\u2026`);
75
+ }
76
+ function registerMcpServer(client, opts, runner = systemCommandRunner(), env = process.env, home = homedir()) {
77
+ if (client.id === "claude_code") return registerClaudeCode(client, opts, mcpConfigPath(client, env, home));
78
+ if (client.id === "codex") return registerCodex(client, opts);
79
+ if (client.id === "cursor") return registerCursor(client, opts);
80
+ if (client.id === "hermes") return registerHermes(client, opts);
81
+ if (client.id === "claude_app") return registerClaudeApp(client, opts);
82
+ const commands = mcpCommands(client.id, opts);
83
+ if (!commands) return { agent: client.id, outcome: "unsupported" };
84
+ if (!runner.has(commands.command)) return { agent: client.id, outcome: "no_command", detail: `${commands.command} is not on PATH` };
85
+ if (opts.dryRun) return { agent: client.id, outcome: "planned", detail: redact(`run ${[commands.command, ...commands.add].join(" ")}`, opts.token) };
86
+ runner.run(commands.command, commands.remove);
87
+ const added = runner.run(commands.command, commands.add);
88
+ if (added.status !== 0) return { agent: client.id, outcome: "failed", detail: redact(added.stderr.trim() || `exit ${added.status}`, opts.token) };
89
+ return { agent: client.id, outcome: "registered" };
90
+ }
91
+ function mcpConfigPath(client, env = process.env, home = homedir()) {
92
+ switch (client.id) {
93
+ case "claude_code":
94
+ return join(env.CLAUDE_CONFIG_DIR || home, ".claude.json");
95
+ case "codex":
96
+ case "grok":
97
+ return join(client.root, "config.toml");
98
+ case "cursor":
99
+ return join(client.root, "mcp.json");
100
+ case "hermes":
101
+ return join(client.root, "config.yaml");
102
+ case "claude_app":
103
+ return join(client.root, "claude_desktop_config.json");
104
+ }
105
+ }
106
+ function readText(path) {
107
+ try {
108
+ return readFileSync(path, "utf8");
109
+ } catch {
110
+ return null;
111
+ }
112
+ }
113
+ function registeredMcpUrl(client, env = process.env, home = homedir()) {
114
+ const raw = readText(mcpConfigPath(client, env, home));
115
+ if (raw === null) return null;
116
+ try {
117
+ let entry;
118
+ if (client.id === "codex" || client.id === "grok") entry = parseToml(raw).mcp_servers?.[MCP_SERVER_NAME];
119
+ else if (client.id === "hermes") entry = parseDocument(raw).toJS()?.mcp_servers?.[MCP_SERVER_NAME];
120
+ else entry = JSON.parse(raw).mcpServers?.[MCP_SERVER_NAME];
121
+ const url = entry?.url;
122
+ return typeof url === "string" ? url : null;
123
+ } catch {
124
+ return null;
125
+ }
126
+ }
127
+ function registeredToolList(client, env = process.env, home = homedir()) {
128
+ const url = registeredMcpUrl(client, env, home);
129
+ if (url === null) return "every";
130
+ try {
131
+ return mcpToolListOf(url) === "short" ? "short" : "every";
132
+ } catch {
133
+ return "every";
134
+ }
135
+ }
136
+ function hasMcpServer(client, env = process.env, home = homedir()) {
137
+ const raw = readText(mcpConfigPath(client, env, home));
138
+ if (raw === null) return false;
139
+ try {
140
+ if (client.id === "codex" || client.id === "grok") return Boolean(parseToml(raw).mcp_servers?.[MCP_SERVER_NAME]);
141
+ if (client.id === "hermes") return parseDocument(raw).hasIn(["mcp_servers", MCP_SERVER_NAME]);
142
+ return Boolean(JSON.parse(raw).mcpServers?.[MCP_SERVER_NAME]);
143
+ } catch {
144
+ return false;
145
+ }
146
+ }
147
+ function planned(client, path, entry, opts) {
148
+ return { agent: client.id, outcome: "planned", detail: `write to ${path}: ${redact(entry, opts.token)}` };
149
+ }
150
+ function written(client, path, text) {
151
+ try {
152
+ writeFileSync(path, text, { encoding: "utf8", mode: 384 });
153
+ } catch (err) {
154
+ return { agent: client.id, outcome: "failed", detail: String(err) };
155
+ }
156
+ return { agent: client.id, outcome: "registered" };
157
+ }
158
+ function tomlTableKey(name) {
159
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
160
+ return `(?:${escaped}|"${escaped}"|'${escaped}')`;
161
+ }
162
+ function withoutTomlServer(text, name) {
163
+ return withTomlServer(text, name, null);
164
+ }
165
+ function withTomlServer(text, name, block) {
166
+ const ours = new RegExp(`^\\s*\\[\\s*mcp_servers\\s*\\.\\s*${tomlTableKey(name)}\\s*(?:\\.[^\\]]*)?\\]\\s*(?:#.*)?$`);
167
+ let skipping = false;
168
+ let placed = false;
169
+ const kept = [];
170
+ for (const line of text.split(/\r?\n/)) {
171
+ if (/^\s*\[/.test(line)) {
172
+ const was = skipping;
173
+ skipping = ours.test(line);
174
+ if (was && !skipping && block !== null) kept.push("");
175
+ }
176
+ if (skipping && !placed && block !== null) {
177
+ kept.push(block);
178
+ placed = true;
179
+ }
180
+ if (!skipping) kept.push(line);
181
+ }
182
+ const rest = kept.join("\n").replace(/\n+$/, "");
183
+ if (block === null || placed) return rest;
184
+ return rest ? `${rest}
185
+
186
+ ${block}` : block;
187
+ }
188
+ function registerCodex(client, opts) {
189
+ const path = mcpConfigPath(client);
190
+ const block = [
191
+ `[mcp_servers.${MCP_SERVER_NAME}]`,
192
+ `url = ${JSON.stringify(opts.mcpUrl)}`,
193
+ `http_headers = { Authorization = ${JSON.stringify(`Bearer ${opts.token}`)} }`
194
+ ].join("\n");
195
+ if (opts.dryRun) return planned(client, path, block, opts);
196
+ const raw = readText(path) ?? "";
197
+ let before;
198
+ try {
199
+ before = parseToml(raw);
200
+ } catch (err) {
201
+ return { agent: client.id, outcome: "failed", detail: `${path} is not valid TOML, left as it was (${String(err).split("\n")[0]})` };
202
+ }
203
+ const text = `${withTomlServer(raw, MCP_SERVER_NAME, block)}
204
+ `;
205
+ if (text === raw) return { agent: client.id, outcome: "registered", detail: "already registered" };
206
+ try {
207
+ const after = parseToml(text);
208
+ const others = Object.keys(before.mcp_servers ?? {}).filter((name) => name !== MCP_SERVER_NAME);
209
+ if (after.mcp_servers?.[MCP_SERVER_NAME]?.url !== opts.mcpUrl || others.some((name) => !after.mcp_servers?.[name])) throw new Error("the edited file lost an entry");
210
+ } catch (err) {
211
+ return { agent: client.id, outcome: "failed", detail: `could not edit ${path} safely, left as it was (${String(err).split("\n")[0]})` };
212
+ }
213
+ return written(client, path, text);
214
+ }
215
+ function registerClaudeCode(client, opts, path) {
216
+ const entry = { type: "http", url: opts.mcpUrl, headers: { Authorization: `Bearer ${opts.token}` } };
217
+ if (opts.dryRun) return planned(client, path, JSON.stringify({ [MCP_SERVER_NAME]: entry }, null, 2), opts);
218
+ const raw = readText(path);
219
+ let existing = {};
220
+ if (raw !== null && raw.trim()) {
221
+ try {
222
+ const parsed = JSON.parse(raw);
223
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("not an object");
224
+ existing = parsed;
225
+ } catch (err) {
226
+ return { agent: client.id, outcome: "failed", detail: `${path} is not valid JSON, left as it was (${String(err).split("\n")[0]})` };
227
+ }
228
+ }
229
+ if (JSON.stringify(existing.mcpServers?.[MCP_SERVER_NAME]) === JSON.stringify(entry)) return { agent: client.id, outcome: "registered", detail: "already registered" };
230
+ const indent = raw ? /^[{[]\r?\n([ \t]+)/.exec(raw)?.[1] ?? 2 : 2;
231
+ const ending = raw === null || raw.endsWith("\n") ? "\n" : "";
232
+ const updated = { ...existing, mcpServers: { ...existing.mcpServers ?? {}, [MCP_SERVER_NAME]: entry } };
233
+ return written(client, path, `${JSON.stringify(updated, null, indent)}${ending}`);
234
+ }
235
+ function registerCursor(client, opts) {
236
+ const path = mcpConfigPath(client);
237
+ const entry = { url: opts.mcpUrl, headers: { Authorization: `Bearer ${opts.token}` } };
238
+ if (opts.dryRun) return planned(client, path, JSON.stringify({ [MCP_SERVER_NAME]: entry }, null, 2), opts);
239
+ let existing = {};
240
+ try {
241
+ const parsed = JSON.parse(readText(path) ?? "");
242
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) existing = parsed;
243
+ } catch {
244
+ existing = {};
245
+ }
246
+ const updated = { ...existing, mcpServers: { ...existing.mcpServers ?? {}, [MCP_SERVER_NAME]: entry } };
247
+ return written(client, path, `${JSON.stringify(updated, null, 2)}
248
+ `);
249
+ }
250
+ function registerClaudeApp(client, opts) {
251
+ if (!opts.sky?.length) return { agent: client.id, outcome: "unsupported", detail: "no sky command to start" };
252
+ const path = mcpConfigPath(client);
253
+ const [command, ...args] = opts.sky;
254
+ const entry = { command, args: [...args, "mcp", "serve"] };
255
+ if (opts.dryRun) return planned(client, path, JSON.stringify({ [MCP_SERVER_NAME]: entry }, null, 2), opts);
256
+ let existing = {};
257
+ const raw = readText(path);
258
+ if (raw !== null && raw.trim()) {
259
+ try {
260
+ const parsed = JSON.parse(raw);
261
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("not an object");
262
+ existing = parsed;
263
+ } catch (err) {
264
+ return { agent: client.id, outcome: "failed", detail: `${path} is not valid JSON, left as it was (${String(err).split("\n")[0]})` };
265
+ }
266
+ }
267
+ const current = existing.mcpServers?.[MCP_SERVER_NAME];
268
+ if (JSON.stringify(current) === JSON.stringify(entry)) return { agent: client.id, outcome: "registered", detail: "already registered" };
269
+ const updated = { ...existing, mcpServers: { ...existing.mcpServers ?? {}, [MCP_SERVER_NAME]: entry } };
270
+ return written(client, path, `${JSON.stringify(updated, null, 2)}
271
+ `);
272
+ }
273
+ function registerHermes(client, opts) {
274
+ const path = mcpConfigPath(client);
275
+ const entry = { url: opts.mcpUrl, headers: { Authorization: `Bearer ${opts.token}` } };
276
+ if (opts.dryRun) return planned(client, path, `mcp_servers.${MCP_SERVER_NAME}: ${JSON.stringify(entry)}`, opts);
277
+ const doc = parseDocument(readText(path) ?? "");
278
+ if (doc.errors.length) return { agent: client.id, outcome: "failed", detail: `${path} is not valid YAML, left as it was (${doc.errors[0].message.split("\n")[0]})` };
279
+ if (doc.contents !== null && !isMap(doc.contents)) {
280
+ return { agent: client.id, outcome: "failed", detail: `${path} is not a YAML mapping, left as it was` };
281
+ }
282
+ doc.setIn(["mcp_servers", MCP_SERVER_NAME], doc.createNode(entry));
283
+ return written(client, path, doc.toString());
284
+ }
285
+ async function refreshMcpRegistrations(opts, clients = detectMcpClients(), runner = systemCommandRunner(), env = process.env, home = homedir()) {
286
+ const registrations = [];
287
+ for (const client of clients.filter((candidate) => candidate.id !== "claude_app" && hasMcpServer(candidate, env, home))) {
288
+ let token;
289
+ try {
290
+ token = await opts.token(client);
291
+ } catch (error) {
292
+ registrations.push({ agent: client.id, outcome: "failed", detail: `no key of its own could be made (${(error instanceof Error ? error.message : String(error)).split("\n")[0]})` });
293
+ continue;
294
+ }
295
+ registrations.push(registerMcpServer(client, { token, mcpUrl: mcpUrlFor(opts.apiBase, registeredToolList(client, env, home)) }, runner, env, home));
296
+ }
297
+ return registrations;
298
+ }
299
+
300
+ export {
301
+ MCP_SERVER_NAME,
302
+ detectHermes,
303
+ claudeAppRoot,
304
+ detectClaudeApp,
305
+ detectMcpClients,
306
+ systemCommandRunner,
307
+ mcpUrlFor,
308
+ mcpCommands,
309
+ NO_TOOLS,
310
+ registerMcpServer,
311
+ mcpConfigPath,
312
+ registeredMcpUrl,
313
+ registeredToolList,
314
+ hasMcpServer,
315
+ withoutTomlServer,
316
+ refreshMcpRegistrations
317
+ };
@@ -1,50 +1,54 @@
1
+ import {
2
+ lastUploads,
3
+ loadSyncConfig
4
+ } from "./chunk-NJPIE762.js";
1
5
  import {
2
6
  CAPTURE_HOOK_ARGS,
3
7
  SetupJournal,
4
8
  isCaptureCommand
5
- } from "./chunk-GDZSCISF.js";
9
+ } from "./chunk-6D36IT7T.js";
6
10
  import {
7
11
  localAgentKey,
8
12
  shortToolCount
9
- } from "./chunk-H7KHMRUZ.js";
13
+ } from "./chunk-CV2ZRIF7.js";
10
14
  import {
11
15
  cachedSettingsBlock,
12
- detectClaudeApp,
13
- detectHermes,
14
- detectLocalAgents,
15
- hasMcpServer,
16
16
  instructionFiles,
17
- mcpConfigPath,
18
- mcpUrlFor,
19
17
  readWorkspaceSettings,
20
- registerMcpServer,
21
- registeredToolList,
22
18
  renderSettingsBlock,
23
19
  settingsBlockState,
24
- systemCommandRunner,
25
20
  workspaceSlug,
26
21
  writeSettingsBlocks
27
- } from "./chunk-RVDXKUWH.js";
28
- import {
29
- lastUploads,
30
- loadSyncConfig
31
- } from "./chunk-46I7RCQQ.js";
22
+ } from "./chunk-A45NGV2Q.js";
32
23
  import {
33
24
  ApiError,
34
25
  api
35
- } from "./chunk-KHJRD4DR.js";
26
+ } from "./chunk-NAIYHS6Q.js";
27
+ import {
28
+ detectClaudeApp,
29
+ detectHermes,
30
+ hasMcpServer,
31
+ mcpConfigPath,
32
+ mcpUrlFor,
33
+ registerMcpServer,
34
+ registeredToolList,
35
+ systemCommandRunner
36
+ } from "./chunk-RKMMLSGJ.js";
37
+ import {
38
+ detectLocalAgents
39
+ } from "./chunk-2H4W5ZKZ.js";
36
40
  import {
37
41
  installSkill,
38
42
  skillState
39
- } from "./chunk-TIP2XS2L.js";
40
- import {
41
- CLI_VERSION
42
- } from "./chunk-E7HNEQ7F.js";
43
+ } from "./chunk-PGX3AGCZ.js";
43
44
  import {
44
45
  apiBase,
45
46
  apiToken,
46
47
  configPath
47
48
  } from "./chunk-XHZJG3QT.js";
49
+ import {
50
+ CLI_VERSION
51
+ } from "./chunk-ZRV3UUW5.js";
48
52
 
49
53
  // src/compute-report.ts
50
54
  import { randomBytes } from "crypto";
@@ -1919,7 +1923,7 @@ ${raw}` : `${line}
1919
1923
  return { trigger: "codex_notify", outcome: "installed", path };
1920
1924
  }
1921
1925
  async function installSchedule(opts) {
1922
- const lib = await import("./trace-library-4F57EGL7.js");
1926
+ const lib = await import("./trace-library-HN5TU5EJ.js");
1923
1927
  if ((opts.platform ?? process.platform) !== "darwin") {
1924
1928
  return { trigger: "schedule", outcome: "skipped", detail: "the 15-minute sweep is macOS only; on Linux add `*/15 * * * * sky trace sync --quiet` to your crontab. The hooks still capture each session" };
1925
1929
  }
@@ -1942,7 +1946,7 @@ async function installSchedule(opts) {
1942
1946
  return { trigger: "schedule", outcome: "installed", path };
1943
1947
  }
1944
1948
  async function installCapture(opts) {
1945
- const lib = await import("./trace-library-4F57EGL7.js");
1949
+ const lib = await import("./trace-library-HN5TU5EJ.js");
1946
1950
  const config = lib.loadSyncConfig();
1947
1951
  if (!config.enabled && config.enabledAt) return { sync: "off", triggers: [] };
1948
1952
  const configFile = lib.syncConfigPath();
@@ -1,17 +1,19 @@
1
1
  import {
2
2
  SKILL_MARKER,
3
3
  SKILL_NAME
4
- } from "./chunk-TIP2XS2L.js";
5
- import {
6
- CLI_VERSION
7
- } from "./chunk-E7HNEQ7F.js";
4
+ } from "./chunk-PGX3AGCZ.js";
8
5
  import {
9
6
  configPath
10
7
  } from "./chunk-XHZJG3QT.js";
8
+ import {
9
+ CLI_VERSION
10
+ } from "./chunk-ZRV3UUW5.js";
11
11
 
12
12
  // src/local-skills.ts
13
- import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
13
+ import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "fs";
14
+ import { homedir } from "os";
14
15
  import { dirname, join, resolve, sep } from "path";
16
+ import { parse as parseYaml } from "yaml";
15
17
  var HISTORY = 20;
16
18
  var SAFE_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
17
19
  function localSkillStatePath() {
@@ -20,7 +22,7 @@ function localSkillStatePath() {
20
22
  function loadLocalSkillState(path = localSkillStatePath()) {
21
23
  try {
22
24
  const parsed = JSON.parse(readFileSync(path, "utf8"));
23
- return { version: 1, workspace: parsed.workspace, checkedAt: parsed.checkedAt, pins: parsed.pins ?? {}, skills: parsed.skills ?? {} };
25
+ return { version: 1, workspace: parsed.workspace, checkedAt: parsed.checkedAt, ...parsed.off ? { off: true } : {}, pins: parsed.pins ?? {}, skills: parsed.skills ?? {} };
24
26
  } catch {
25
27
  return { version: 1, pins: {}, skills: {} };
26
28
  }
@@ -74,6 +76,7 @@ async function syncLocalSkills(opts) {
74
76
  const now = (opts.now ?? (() => /* @__PURE__ */ new Date()))().toISOString();
75
77
  const statePath = opts.statePath ?? localSkillStatePath();
76
78
  const state = loadLocalSkillState(statePath);
79
+ if (state.off) return { workspace: opts.workspace, checked: false, skills: [], off: true };
77
80
  const before = JSON.stringify({ pins: state.pins, skills: state.skills });
78
81
  const have = installedFingerprints(state, opts.targets);
79
82
  const answer = await opts.request("GET", `/skills/local${have.length ? `?have=${encodeURIComponent(have.join(","))}` : ""}`, opts.workspace);
@@ -163,12 +166,60 @@ function unpinLocalSkill(name, statePath) {
163
166
  saveLocalSkillState(state, statePath);
164
167
  return true;
165
168
  }
169
+ function turnOffLocalSkills(targets, statePath) {
170
+ const state = loadLocalSkillState(statePath);
171
+ const names = Object.keys(state.skills).sort();
172
+ for (const name of names) {
173
+ for (const target of targets) {
174
+ const dir = join(target.skillsDir, name);
175
+ if (deliveredHere(dir)) rmSync(dir, { recursive: true, force: true });
176
+ }
177
+ }
178
+ saveLocalSkillState({ version: 1, workspace: state.workspace, checkedAt: state.checkedAt, off: true, pins: {}, skills: {} }, statePath);
179
+ return names;
180
+ }
181
+ function turnOnLocalSkills(statePath) {
182
+ const state = loadLocalSkillState(statePath);
183
+ if (!state.off) return false;
184
+ const { off: _off, ...rest } = state;
185
+ saveLocalSkillState(rest, statePath);
186
+ return true;
187
+ }
166
188
  function checkedWithin(ms, now = /* @__PURE__ */ new Date(), statePath) {
167
189
  const at = Date.parse(loadLocalSkillState(statePath).checkedAt ?? "");
168
190
  return Number.isFinite(at) && now.getTime() - at < ms;
169
191
  }
170
- function skillTargets(agents, hermesRoot) {
171
- return [...agents.map((agent) => ({ id: agent.id, skillsDir: agent.skillsDir })), ...hermesRoot ? [{ id: "hermes", skillsDir: join(hermesRoot, "skills") }] : []];
192
+ var realDir = (dir) => {
193
+ try {
194
+ return realpathSync(dir);
195
+ } catch {
196
+ return resolve(dir);
197
+ }
198
+ };
199
+ function hermesExternalSkillDirs(hermesRoot, home = homedir()) {
200
+ try {
201
+ const config = parseYaml(readFileSync(join(hermesRoot, "config.yaml"), "utf8"));
202
+ const dirs = config?.skills?.external_dirs;
203
+ if (!Array.isArray(dirs)) return [];
204
+ return dirs.filter((dir) => typeof dir === "string" && dir.length > 0).map((dir) => dir === "~" ? home : dir.startsWith("~/") ? join(home, dir.slice(2)) : resolve(hermesRoot, dir));
205
+ } catch {
206
+ return [];
207
+ }
208
+ }
209
+ function skillTargets(agents, hermesRoot, home = homedir(), opts = {}) {
210
+ const seen = /* @__PURE__ */ new Set();
211
+ const targets = [];
212
+ for (const agent of agents) {
213
+ const real = realDir(agent.skillsDir);
214
+ if (seen.has(real)) continue;
215
+ seen.add(real);
216
+ targets.push({ id: agent.id, skillsDir: agent.skillsDir });
217
+ }
218
+ if (!hermesRoot) return targets;
219
+ const hermesDir = join(hermesRoot, "skills");
220
+ if (seen.has(realDir(hermesDir))) return targets;
221
+ if (!opts.all && hermesExternalSkillDirs(hermesRoot, home).some((dir) => seen.has(realDir(dir)))) return targets;
222
+ return [...targets, { id: "hermes", skillsDir: hermesDir }];
172
223
  }
173
224
  function revisionAt(state, name, at) {
174
225
  const installs = state.skills[name]?.installs ?? [];
@@ -187,7 +238,10 @@ export {
187
238
  syncLocalSkills,
188
239
  pinLocalSkill,
189
240
  unpinLocalSkill,
241
+ turnOffLocalSkills,
242
+ turnOnLocalSkills,
190
243
  checkedWithin,
244
+ hermesExternalSkillDirs,
191
245
  skillTargets,
192
246
  revisionAt
193
247
  };
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var CLI_VERSION = "3.48.1";
2
+ var CLI_VERSION = "3.48.2";
3
3
  var USER_AGENT = `sky-cli/${CLI_VERSION} (${process.platform}; node/${process.versions.node})`;
4
4
 
5
5
  export {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  api
3
- } from "./chunk-KHJRD4DR.js";
4
- import "./chunk-E7HNEQ7F.js";
3
+ } from "./chunk-NAIYHS6Q.js";
5
4
  import "./chunk-XHZJG3QT.js";
5
+ import "./chunk-ZRV3UUW5.js";
6
6
  import "./chunk-MLKGABMK.js";
7
7
 
8
8
  // src/compute.ts
@@ -10,17 +10,19 @@ import {
10
10
  reportComputer,
11
11
  savedMachineKey,
12
12
  upkeepComputer
13
- } from "./chunk-LVHQILKX.js";
14
- import "./chunk-GDZSCISF.js";
15
- import "./chunk-H7KHMRUZ.js";
16
- import "./chunk-RVDXKUWH.js";
17
- import "./chunk-46I7RCQQ.js";
18
- import "./chunk-KHJRD4DR.js";
19
- import "./chunk-NDVCYVW5.js";
20
- import "./chunk-X4DBI7R7.js";
21
- import "./chunk-TIP2XS2L.js";
22
- import "./chunk-E7HNEQ7F.js";
13
+ } from "./chunk-UJS4JIE2.js";
14
+ import "./chunk-NJPIE762.js";
15
+ import "./chunk-6D36IT7T.js";
16
+ import "./chunk-CV2ZRIF7.js";
17
+ import "./chunk-A45NGV2Q.js";
18
+ import "./chunk-NAIYHS6Q.js";
19
+ import "./chunk-RKMMLSGJ.js";
20
+ import "./chunk-2H4W5ZKZ.js";
21
+ import "./chunk-FVIPGI3E.js";
22
+ import "./chunk-ZF2P6PKM.js";
23
+ import "./chunk-PGX3AGCZ.js";
23
24
  import "./chunk-XHZJG3QT.js";
25
+ import "./chunk-ZRV3UUW5.js";
24
26
  import "./chunk-OJ5ERABF.js";
25
27
  import "./chunk-W24YSGH4.js";
26
28
  import "./chunk-MLKGABMK.js";