@inupedia/spotlight-client 0.2.9 → 0.2.11
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/node/capabilities/skillScanner.d.ts +31 -0
- package/dist/node/capabilities/skillScanner.d.ts.map +1 -0
- package/dist/node/capabilities/skillScanner.js +109 -0
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type SkillScanMode = "compat" | "strict";
|
|
2
|
+
export type SkillRootInput = {
|
|
3
|
+
path: string;
|
|
4
|
+
kind?: "canonical" | "inupedia-compat" | "claude-compat" | "custom";
|
|
5
|
+
};
|
|
6
|
+
export type ScannedSkill = {
|
|
7
|
+
name: string;
|
|
8
|
+
root: string;
|
|
9
|
+
directory: string;
|
|
10
|
+
skillFile: string;
|
|
11
|
+
sourceKind: NonNullable<SkillRootInput["kind"]>;
|
|
12
|
+
};
|
|
13
|
+
export type SkillScanDiagnostic = {
|
|
14
|
+
code: "SKILL_NAME_SHADOWED" | "SKILL_NAME_COLLISION";
|
|
15
|
+
severity: "warning" | "error";
|
|
16
|
+
name: string;
|
|
17
|
+
selected?: string;
|
|
18
|
+
candidates: string[];
|
|
19
|
+
};
|
|
20
|
+
export type ScanProjectSkillsOptions = {
|
|
21
|
+
projectRoot: string;
|
|
22
|
+
mode?: SkillScanMode;
|
|
23
|
+
skillRoots?: readonly (string | SkillRootInput)[];
|
|
24
|
+
};
|
|
25
|
+
export type SkillScanResult = {
|
|
26
|
+
skills: ScannedSkill[];
|
|
27
|
+
diagnostics: SkillScanDiagnostic[];
|
|
28
|
+
};
|
|
29
|
+
export declare const DEFAULT_SKILL_ROOTS: readonly Required<SkillRootInput>[];
|
|
30
|
+
export declare function scanProjectSkills(options: ScanProjectSkillsOptions): Promise<SkillScanResult>;
|
|
31
|
+
//# sourceMappingURL=skillScanner.d.ts.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AC,eAAe,CAAC,CAkD1B"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { lstat, readdir } from "node:fs/promises";
|
|
2
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
|
+
export const DEFAULT_SKILL_ROOTS = [
|
|
4
|
+
{ path: ".agents/skills", kind: "canonical" },
|
|
5
|
+
{ path: ".inupedia/skills", kind: "inupedia-compat" },
|
|
6
|
+
{ path: ".claude/skills", kind: "claude-compat" },
|
|
7
|
+
];
|
|
8
|
+
function compareUtf8(left, right) {
|
|
9
|
+
return Buffer.compare(Buffer.from(left, "utf8"), Buffer.from(right, "utf8"));
|
|
10
|
+
}
|
|
11
|
+
function toPosix(path) {
|
|
12
|
+
return path.split(sep).join("/");
|
|
13
|
+
}
|
|
14
|
+
function normalizeRoot(input) {
|
|
15
|
+
if (typeof input === "string")
|
|
16
|
+
return { path: input, kind: "custom" };
|
|
17
|
+
return { path: input.path, kind: input.kind ?? "custom" };
|
|
18
|
+
}
|
|
19
|
+
async function isRegularFile(path) {
|
|
20
|
+
try {
|
|
21
|
+
return (await lstat(path)).isFile();
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (error.code === "ENOENT")
|
|
25
|
+
return false;
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function scanRoot(projectRoot, rootInput) {
|
|
30
|
+
const rootPath = isAbsolute(rootInput.path)
|
|
31
|
+
? rootInput.path
|
|
32
|
+
: resolve(projectRoot, rootInput.path);
|
|
33
|
+
let entries;
|
|
34
|
+
try {
|
|
35
|
+
entries = await readdir(rootPath, { withFileTypes: true });
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const code = error.code;
|
|
39
|
+
if (code === "ENOENT" || code === "ENOTDIR")
|
|
40
|
+
return [];
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
const root = toPosix(relative(projectRoot, rootPath));
|
|
44
|
+
const skills = [];
|
|
45
|
+
for (const entry of entries
|
|
46
|
+
.filter((candidate) => candidate.isDirectory())
|
|
47
|
+
.sort((left, right) => compareUtf8(left.name, right.name))) {
|
|
48
|
+
const directoryPath = resolve(rootPath, entry.name);
|
|
49
|
+
const skillFilePath = resolve(directoryPath, "SKILL.md");
|
|
50
|
+
if (!(await isRegularFile(skillFilePath)))
|
|
51
|
+
continue;
|
|
52
|
+
skills.push({
|
|
53
|
+
name: entry.name,
|
|
54
|
+
root,
|
|
55
|
+
directory: toPosix(relative(projectRoot, directoryPath)),
|
|
56
|
+
skillFile: toPosix(relative(projectRoot, skillFilePath)),
|
|
57
|
+
sourceKind: rootInput.kind,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return skills;
|
|
61
|
+
}
|
|
62
|
+
export async function scanProjectSkills(options) {
|
|
63
|
+
const projectRoot = resolve(options.projectRoot);
|
|
64
|
+
const roots = (options.skillRoots ?? DEFAULT_SKILL_ROOTS).map(normalizeRoot);
|
|
65
|
+
const candidates = (await Promise.all(roots.map((root) => scanRoot(projectRoot, root)))).flat();
|
|
66
|
+
if (options.mode === "strict") {
|
|
67
|
+
const grouped = new Map();
|
|
68
|
+
for (const candidate of candidates) {
|
|
69
|
+
const group = grouped.get(candidate.name) ?? [];
|
|
70
|
+
group.push(candidate);
|
|
71
|
+
grouped.set(candidate.name, group);
|
|
72
|
+
}
|
|
73
|
+
const skills = [];
|
|
74
|
+
const diagnostics = [];
|
|
75
|
+
for (const [name, group] of grouped) {
|
|
76
|
+
if (group.length === 1) {
|
|
77
|
+
skills.push(group[0]);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
diagnostics.push({
|
|
81
|
+
code: "SKILL_NAME_COLLISION",
|
|
82
|
+
severity: "error",
|
|
83
|
+
name,
|
|
84
|
+
candidates: group.map((candidate) => candidate.skillFile),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return { skills, diagnostics };
|
|
88
|
+
}
|
|
89
|
+
const selected = new Map();
|
|
90
|
+
const diagnostics = [];
|
|
91
|
+
for (const candidate of candidates) {
|
|
92
|
+
const winner = selected.get(candidate.name);
|
|
93
|
+
if (!winner) {
|
|
94
|
+
selected.set(candidate.name, candidate);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
diagnostics.push({
|
|
98
|
+
code: "SKILL_NAME_SHADOWED",
|
|
99
|
+
severity: "warning",
|
|
100
|
+
name: candidate.name,
|
|
101
|
+
selected: winner.skillFile,
|
|
102
|
+
candidates: [winner.skillFile, candidate.skillFile],
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
skills: [...selected.values()],
|
|
107
|
+
diagnostics,
|
|
108
|
+
};
|
|
109
|
+
}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { joinSkillScriptPath, type SkillScriptRunResult, } from "../skillScriptPath.js";
|
|
2
2
|
export { createNodeSkillScriptRunner } from "./skillScriptRunner.js";
|
|
3
|
+
export { DEFAULT_SKILL_ROOTS, scanProjectSkills, type ScanProjectSkillsOptions, type ScannedSkill, type SkillRootInput, type SkillScanDiagnostic, type SkillScanMode, type SkillScanResult, } from "./capabilities/skillScanner.js";
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,eAAe,GACrB,MAAM,gCAAgC,CAAC"}
|
package/dist/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inupedia/spotlight-client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "HTTP/SSE helpers and host tool bridge for Inupedia Spotlight (monorepo workspace package)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@babel/traverse": "^7.28.5",
|
|
41
41
|
"@babel/types": "^7.28.5",
|
|
42
42
|
"magic-string": "^0.30.21",
|
|
43
|
-
"@inupedia/spotlight-protocol": "0.2.
|
|
43
|
+
"@inupedia/spotlight-protocol": "0.2.11"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
|