@antelopejs/agent-skills 0.1.0 → 0.2.0

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 CHANGED
@@ -21,7 +21,7 @@ Each result is `{ name, version, dir, skillDirs, kind }`. `skillDirs` are absolu
21
21
 
22
22
  Candidates are ordered, and the first one to carry a package name keeps it:
23
23
 
24
- 1. the `modules`, in the order given;
24
+ 1. the `modules`, in the order given, then the `installed` directories whose `package.json` sets `antelopeJs.implements`;
25
25
  2. the `dependencies` and `optionalDependencies` of every module, resolved from the module's real path through `node_modules/<dep>` in its ancestors;
26
26
  3. the `dependencies`, `optionalDependencies` and `devDependencies` of `project`, resolved the same way;
27
27
  4. the `installed` directories.
package/index.d.ts CHANGED
@@ -36,7 +36,11 @@ export interface CollectSkillPackagesInput {
36
36
  modules: readonly ModuleRef[];
37
37
  /** The project root; its `dependencies`, `optionalDependencies` and `devDependencies` are read. */
38
38
  project?: string;
39
- /** Extra package directories, lowest priority. */
39
+ /**
40
+ * Extra package directories, lowest priority. One whose `package.json` sets
41
+ * `antelopeJs.implements` is a module the runtime can load, so it also counts
42
+ * as a module, after {@link CollectSkillPackagesInput.modules}.
43
+ */
40
44
  installed?: readonly string[];
41
45
  /** Called with a message for each skill directory dropped because it escapes its package. */
42
46
  onWarning?: (message: string) => void;
@@ -44,8 +48,9 @@ export interface CollectSkillPackagesInput {
44
48
 
45
49
  /**
46
50
  * Collects the packages that ship agent skills, in priority order, one per
47
- * package name: modules, then their dependencies, then the project's
48
- * dependencies, then `installed`. The first candidate to carry a name keeps it.
51
+ * package name: modules (installed interface implementations included), then
52
+ * their dependencies, then the project's dependencies, then `installed`. The
53
+ * first candidate to carry a name keeps it.
49
54
  * Only packages with at least one skill directory are returned.
50
55
  */
51
56
  export function collectSkillPackages(
package/index.mjs CHANGED
@@ -20,6 +20,7 @@ const KIND = {
20
20
  * @property {string[]} dependencies Names under `dependencies`.
21
21
  * @property {string[]} optionalDependencies Names under `optionalDependencies`.
22
22
  * @property {string[]} devDependencies Names under `devDependencies`.
23
+ * @property {boolean} implementsInterface Whether `antelopeJs.implements` is set.
23
24
  */
24
25
 
25
26
  /**
@@ -90,6 +91,7 @@ function parseManifest(raw) {
90
91
  dependencies: dependencyNames(raw.dependencies),
91
92
  optionalDependencies: dependencyNames(raw.optionalDependencies),
92
93
  devDependencies: dependencyNames(raw.devDependencies),
94
+ implementsInterface: isRecord(antelopeJs) && Boolean(antelopeJs.implements),
93
95
  };
94
96
  }
95
97
 
@@ -125,12 +127,13 @@ function realpathOrSelf(path) {
125
127
  * entered from inside the store.
126
128
  * @param {string} fromDir
127
129
  * @param {string} dep
130
+ * @param {(dir: string) => Manifest | null} manifestOf
128
131
  * @returns {string | null}
129
132
  */
130
- function resolveDependencyDir(fromDir, dep) {
133
+ function resolveDependencyDir(fromDir, dep, manifestOf) {
131
134
  for (let dir = realpathOrSelf(fromDir); ; dir = dirname(dir)) {
132
135
  const candidate = join(dir, NODE_MODULES_DIR, dep);
133
- if (readManifest(candidate) !== null) return candidate;
136
+ if (manifestOf(candidate) !== null) return candidate;
134
137
  if (dirname(dir) === dir) return null;
135
138
  }
136
139
  }
@@ -170,11 +173,12 @@ function skillDirsOf({ name, dir, manifest }, onWarning) {
170
173
  * @param {string} root
171
174
  * @param {string[]} names
172
175
  * @param {import("./index.js").SkillPackageKind} kind
176
+ * @param {(dir: string) => Manifest | null} manifestOf
173
177
  * @returns {Candidate[]}
174
178
  */
175
- function dependencyCandidates(root, names, kind) {
179
+ function dependencyCandidates(root, names, kind, manifestOf) {
176
180
  return names.flatMap((dep) => {
177
- const dir = resolveDependencyDir(root, dep);
181
+ const dir = resolveDependencyDir(root, dep, manifestOf);
178
182
  return dir === null ? [] : [{ dir, kind, fallbackName: dep }];
179
183
  });
180
184
  }
@@ -185,17 +189,21 @@ function dependencyCandidates(root, names, kind) {
185
189
  * @returns {Candidate[]}
186
190
  */
187
191
  function candidatesOf({ modules, project, installed = [] }, manifestOf) {
188
- const own = modules.map((entry) => ({
192
+ /** @type {import("./index.js").ModuleRef[]} */
193
+ const installedModules = installed
194
+ .filter((dir) => manifestOf(dir)?.implementsInterface)
195
+ .map((dir) => ({ dir }));
196
+ const own = [...modules, ...installedModules].map((entry) => ({
189
197
  dir: entry.dir,
190
198
  kind: KIND.module,
191
199
  fallbackName: entry.id,
192
200
  }));
193
- const moduleDependencies = modules.flatMap((entry) => {
201
+ const moduleDependencies = own.flatMap((entry) => {
194
202
  const manifest = manifestOf(entry.dir);
195
203
  const names = manifest
196
204
  ? [...manifest.dependencies, ...manifest.optionalDependencies]
197
205
  : [];
198
- return dependencyCandidates(entry.dir, names, KIND.dependency);
206
+ return dependencyCandidates(entry.dir, names, KIND.dependency, manifestOf);
199
207
  });
200
208
  const projectManifest = project === undefined ? null : manifestOf(project);
201
209
  const projectDependencies =
@@ -209,6 +217,7 @@ function candidatesOf({ modules, project, installed = [] }, manifestOf) {
209
217
  ...projectManifest.devDependencies,
210
218
  ],
211
219
  KIND.project,
220
+ manifestOf,
212
221
  );
213
222
  const installedDirs = installed.map((dir) => ({
214
223
  dir,
@@ -227,7 +236,8 @@ function candidatesOf({ modules, project, installed = [] }, manifestOf) {
227
236
  * Collects the packages that ship agent skills, in priority order, one per
228
237
  * package name: the first candidate to carry a name keeps it.
229
238
  *
230
- * The candidates, in order: the modules themselves; the dependencies and
239
+ * The candidates, in order: the modules themselves, then the `installed`
240
+ * directories whose manifest sets `antelopeJs.implements`; the dependencies and
231
241
  * optional dependencies of every module; the dependencies, optional
232
242
  * dependencies and dev dependencies of `project`; the `installed` package
233
243
  * directories. A candidate with a readable manifest and a name reserves that
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/agent-skills",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Finds the agent skills that AntelopeJS packages ship, so every tool that loads them sees the same ones.",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -8,7 +8,7 @@
8
8
  "claude-code",
9
9
  "codex"
10
10
  ],
11
- "homepage": "https://github.com/AntelopeJS/agent-skills/tree/main/packages/agent-skills#readme",
11
+ "homepage": "https://github.com/AntelopeJS/agent-skills/tree/main/plugin/packages/agent-skills#readme",
12
12
  "bugs": {
13
13
  "url": "https://github.com/AntelopeJS/agent-skills/issues"
14
14
  },
@@ -16,7 +16,7 @@
16
16
  "repository": {
17
17
  "type": "git",
18
18
  "url": "git+https://github.com/AntelopeJS/agent-skills.git",
19
- "directory": "packages/agent-skills"
19
+ "directory": "plugin/packages/agent-skills"
20
20
  },
21
21
  "files": [
22
22
  "index.mjs",