@robot-inventor/agent-skills 1.1.0 → 1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robot-inventor/agent-skills",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Roboin's personal collection of Agent Skills.",
5
5
  "homepage": "https://github.com/Robot-Inventor/agent-skills#readme",
6
6
  "bugs": {
@@ -15,6 +15,9 @@
15
15
  "type": "module",
16
16
  "main": "./scripts/opencode.ts",
17
17
  "files": ["./hooks/", "./skills/", "./scripts/"],
18
+ "engines": {
19
+ "opencode": ">=1.18.29"
20
+ },
18
21
  "publishConfig": {
19
22
  "access": "public",
20
23
  "provenance": true
@@ -23,6 +26,9 @@
23
26
  "ci:version": "changeset version && bun ./scripts/syncVersion.ts && git add .",
24
27
  "ci:publish": "changeset publish"
25
28
  },
29
+ "dependencies": {
30
+ "@opencode/plugin": "^2.0.15"
31
+ },
26
32
  "devDependencies": {
27
33
  "@changesets/changelog-github": "^1.0.0",
28
34
  "@changesets/cli": "^3.0.0",
package/scripts/codex.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { exists, readFile } from "node:fs/promises";
2
- import { dirname, join, parse } from "node:path";
3
2
  import { SKILLS } from "./skills";
3
+ import { join } from "node:path";
4
4
 
5
5
  const main = async () => {
6
6
  let input = "";
@@ -1,26 +1,46 @@
1
- import type { Plugin } from "@opencode-ai/plugin";
1
+ import { exists, readFile } from "node:fs/promises";
2
+ import { Plugin } from "@opencode/plugin";
3
+ import type { PluginModule } from "@opencode-ai/plugin";
2
4
  import { SKILLS } from "./skills";
3
- import { exists } from "node:fs/promises";
4
- import { join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
+ import { join } from "node:path";
6
7
 
7
- const plugin: Plugin = async ({ project, directory }) => {
8
- const isWebProject = await exists(join(directory, "package.json"));
9
- const skills = isWebProject ? SKILLS.web : SKILLS.nonWeb;
8
+ const selectSkills = async (directory: string) =>
9
+ (await exists(join(directory, "package.json"))) ? SKILLS.web : SKILLS.nonWeb;
10
10
 
11
- return {
12
- config: async (config) => {
13
- config.instructions ??= [];
11
+ const skillPath = (skill: string) => fileURLToPath(new URL(`../skills/${skill}/SKILL.md`, import.meta.url));
14
12
 
15
- for (const skill of skills) {
16
- const path = fileURLToPath(new URL(`../skills/${skill}/SKILL.md`, import.meta.url));
13
+ const plugin = {
14
+ ...Plugin.define({
15
+ id: "io.roboin.agent-skills",
16
+ async setup(ctx) {
17
+ const skills = await selectSkills(ctx.location.directory);
18
+ const instructions = await Promise.all(skills.map((skill) => readFile(skillPath(skill), "utf8")));
17
19
 
18
- if (!config.instructions.includes(path)) {
19
- config.instructions.push(path);
20
+ await ctx.session.hook("context", (event) => {
21
+ for (const text of instructions) {
22
+ event.system.push({ type: "text", text });
20
23
  }
21
- }
24
+ });
22
25
  }
23
- };
24
- };
26
+ }),
27
+ async server({ directory }) {
28
+ const skills = await selectSkills(directory);
29
+
30
+ return {
31
+ config: async (config) => {
32
+ config.instructions ??= [];
33
+
34
+ for (const skill of skills) {
35
+ const path = skillPath(skill);
36
+
37
+ if (!config.instructions.includes(path)) {
38
+ config.instructions.push(path);
39
+ }
40
+ }
41
+ }
42
+ };
43
+ }
44
+ } as const satisfies PluginModule;
25
45
 
26
- export { plugin };
46
+ export default plugin;
@@ -1,4 +1,4 @@
1
- import fs from "fs/promises";
1
+ import fs from "node:fs/promises";
2
2
  import packageJson from "../package.json";
3
3
  import pluginJson from "../.codex-plugin/plugin.json";
4
4