@saturn-universe/protocol 0.1.2-dev.2 → 0.1.2-dev.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/dist/skills.d.ts CHANGED
@@ -38,6 +38,7 @@ export declare function localSkillSearchDirectories(workspaceRoot: string, env?:
38
38
  readonly scope: 'project' | 'user';
39
39
  })[];
40
40
  export declare function isInsideSkillDir(rootDir: string, targetPath: string): boolean;
41
+ export declare function userModeDirectories(env?: NodeJS.ProcessEnv): Promise<string[]>;
41
42
  export declare function validateRelativeSkillResourcePath(rawPath: unknown): {
42
43
  readonly ok: true;
43
44
  readonly normalized: string;
package/dist/skills.js CHANGED
@@ -37,6 +37,25 @@ export function isInsideSkillDir(rootDir, targetPath) {
37
37
  return false;
38
38
  return rel !== '..' && !rel.startsWith(`..${path.sep}`) && !rel.startsWith('../');
39
39
  }
40
+ export async function userModeDirectories(env = process.env) {
41
+ try {
42
+ const home = await realpath(saturnHomeDir(env));
43
+ const modes = path.join(home, 'modes');
44
+ if (path.relative(modes, await realpath(modes)) !== '')
45
+ return [];
46
+ const entries = await readdir(modes, { withFileTypes: true });
47
+ return entries
48
+ .filter((entry) => entry.isDirectory())
49
+ .map((entry) => entry.name)
50
+ .sort()
51
+ .map((name) => path.join(modes, name));
52
+ }
53
+ catch (error) {
54
+ if (['ENOENT', 'ENOTDIR'].includes(error.code ?? ''))
55
+ return [];
56
+ throw error;
57
+ }
58
+ }
40
59
  export function validateRelativeSkillResourcePath(rawPath) {
41
60
  if (typeof rawPath !== 'string' || !rawPath.trim()) {
42
61
  return { ok: false, code: 'INVALID_PATH', message: 'Resource path must be a non-empty relative path.' };
@@ -330,7 +349,7 @@ export async function discoverAgentSkills(workspaceRoot, options = {}) {
330
349
  const env = options.env ?? process.env;
331
350
  const byName = new Map();
332
351
  const scannedDirs = new Map();
333
- const registerFromDir = async (dir, scope, source, indexedBySecurityPlugin, allowedSkills) => {
352
+ const registerFromDir = async (dir, scope, source, indexedBySecurityPlugin, allowedSkills, packageRoot) => {
334
353
  let resolvedDir;
335
354
  try {
336
355
  resolvedDir = await realpath(dir);
@@ -338,6 +357,8 @@ export async function discoverAgentSkills(workspaceRoot, options = {}) {
338
357
  catch {
339
358
  return;
340
359
  }
360
+ if (packageRoot && !isInsideSkillDir(packageRoot, resolvedDir))
361
+ return;
341
362
  const dirKey = process.platform === 'win32' ? resolvedDir.toLowerCase() : resolvedDir;
342
363
  const previous = scannedDirs.get(dirKey);
343
364
  if (previous && !indexedBySecurityPlugin)
@@ -347,6 +368,8 @@ export async function discoverAgentSkills(workspaceRoot, options = {}) {
347
368
  scannedDirs.set(dirKey, candidates);
348
369
  const allowSet = allowedSkills ? new Set(allowedSkills) : undefined;
349
370
  for (const skill of candidates) {
371
+ if (packageRoot && !isInsideSkillDir(resolvedDir, skill.rootDir))
372
+ continue;
350
373
  if (allowSet && !allowSet.has(skill.name) && !allowSet.has(path.basename(skill.rootDir))) {
351
374
  continue;
352
375
  }
@@ -370,6 +393,9 @@ export async function discoverAgentSkills(workspaceRoot, options = {}) {
370
393
  for (const { dir, scope, source } of localSkillSearchDirectories(workspaceRoot, env)) {
371
394
  await registerFromDir(dir, scope, source);
372
395
  }
396
+ for (const dir of await userModeDirectories(env)) {
397
+ await registerFromDir(path.join(dir, 'skills'), 'user', `user:.saturn/modes/${path.basename(dir)}/skills`, undefined, undefined, dir);
398
+ }
373
399
  for (const modeDir of options.modeSkillDirs ?? []) {
374
400
  await registerFromDir(modeDir.dir, 'mode', modeDir.source, modeDir.indexedBySecurityPlugin, modeDir.allowedSkills);
375
401
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@saturn-universe/protocol",
3
- "version": "0.1.2-dev.2",
3
+ "version": "0.1.2-dev.3",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
8
8
  ],
9
9
  "dependencies": {
10
- "@saturn-universe/core": "0.1.2-dev.2",
10
+ "@saturn-universe/core": "0.1.2-dev.3",
11
11
  "smol-toml": "1.9.1",
12
12
  "zod": "4.6.0"
13
13
  },