opencode-agent-skills-md 1.0.1 → 1.1.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.
Files changed (129) hide show
  1. package/dist/cli.mjs +770 -0
  2. package/dist/plugin.mjs +1138 -0
  3. package/dist/src/cli/config.d.ts +144 -0
  4. package/dist/src/cli/install.d.ts +33 -0
  5. package/dist/src/cli/main.d.ts +11 -0
  6. package/dist/src/cli/real-fs.d.ts +6 -0
  7. package/dist/src/cli/status.d.ts +34 -0
  8. package/dist/src/cli/uninstall.d.ts +22 -0
  9. package/dist/src/host.d.ts +51 -0
  10. package/dist/src/index.d.ts +17 -0
  11. package/dist/src/plugin.d.ts +35 -0
  12. package/dist/src/sdk.d.ts +51 -0
  13. package/dist/src/tools.d.ts +86 -0
  14. package/package.json +48 -18
  15. package/.beads/.local_version +0 -1
  16. package/.beads/README.md +0 -81
  17. package/.beads/config.yaml +0 -61
  18. package/.beads/deletions.jsonl +0 -1
  19. package/.beads/issues.jsonl +0 -64
  20. package/.beads/metadata.json +0 -4
  21. package/.gitattributes +0 -3
  22. package/.github/CODEOWNERS +0 -1
  23. package/.github/copilot-instructions.md +0 -78
  24. package/.github/dependabot.yml +0 -13
  25. package/.github/workflows/release.yml +0 -51
  26. package/.opencode/command/test-compaction.md +0 -9
  27. package/.opencode/command/test-find-skills.md +0 -7
  28. package/.opencode/command/test-read-skill-file.md +0 -14
  29. package/.opencode/command/test-run-skill-script.md +0 -13
  30. package/.opencode/command/test-skills.md +0 -14
  31. package/.opencode/command/test-use-skill.md +0 -10
  32. package/.opencode/skills/git-helper/SKILL.md +0 -65
  33. package/.opencode/skills/test-skill/SKILL.md +0 -43
  34. package/.opencode/skills/test-skill/example-config.json +0 -16
  35. package/.opencode/skills/test-skill/helper-docs.md +0 -29
  36. package/.opencode/skills/test-skill/scripts/echo-args +0 -14
  37. package/.opencode/skills/test-skill/scripts/greet +0 -6
  38. package/AGENTS.md +0 -43
  39. package/CHANGELOG.md +0 -178
  40. package/Justfile +0 -39
  41. package/README.md +0 -220
  42. package/openspec/changes/archive/2026-06-14-skills-core-decouple/specs/core-decoupling/spec.md +0 -74
  43. package/openspec/changes/archive/2026-06-14-skills-core-decouple/tasks.md +0 -64
  44. package/openspec/changes/archive/2026-06-14-skills-core-decouple/verify-report.md +0 -75
  45. package/openspec/changes/archive/2026-06-17-fix-skill-loading-regression/apply-progress.md +0 -136
  46. package/openspec/changes/archive/2026-06-17-fix-skill-loading-regression/archive-report.md +0 -77
  47. package/openspec/changes/archive/2026-06-17-fix-skill-loading-regression/design.md +0 -89
  48. package/openspec/changes/archive/2026-06-17-fix-skill-loading-regression/proposal.md +0 -65
  49. package/openspec/changes/archive/2026-06-17-fix-skill-loading-regression/specs/core-decoupling/spec.md +0 -77
  50. package/openspec/changes/archive/2026-06-17-fix-skill-loading-regression/tasks.md +0 -65
  51. package/openspec/changes/archive/2026-06-17-fix-skill-loading-regression/verify-report.md +0 -165
  52. package/openspec/specs/core-decoupling/spec.md +0 -110
  53. package/packages/core/package.json +0 -30
  54. package/packages/core/src/content.d.ts +0 -16
  55. package/packages/core/src/content.ts +0 -30
  56. package/packages/core/src/debug.ts +0 -16
  57. package/packages/core/src/discovery.d.ts +0 -86
  58. package/packages/core/src/discovery.ts +0 -257
  59. package/packages/core/src/index.d.ts +0 -20
  60. package/packages/core/src/index.ts +0 -55
  61. package/packages/core/src/match.d.ts +0 -19
  62. package/packages/core/src/match.ts +0 -75
  63. package/packages/core/src/parse.d.ts +0 -26
  64. package/packages/core/src/parse.ts +0 -141
  65. package/packages/core/src/scripts.d.ts +0 -17
  66. package/packages/core/src/scripts.ts +0 -79
  67. package/packages/core/src/search.d.ts +0 -83
  68. package/packages/core/src/search.ts +0 -188
  69. package/packages/core/src/types.d.ts +0 -82
  70. package/packages/core/src/types.ts +0 -131
  71. package/packages/core/src/walk.ts +0 -109
  72. package/packages/core/tests/agnostic.test.ts +0 -346
  73. package/packages/core/tests/content.test.ts +0 -65
  74. package/packages/core/tests/discovery.test.ts +0 -370
  75. package/packages/core/tests/package-boundary.test.ts +0 -310
  76. package/packages/core/tests/parse-trigger.test.ts +0 -282
  77. package/packages/core/tests/search.test.ts +0 -374
  78. package/packages/core/tests/subpath.test.ts +0 -87
  79. package/packages/core/tsconfig.json +0 -10
  80. package/packages/opencode-agent-skills-md/package.json +0 -66
  81. package/packages/opencode-agent-skills-md/rolldown.config.js +0 -47
  82. package/packages/opencode-agent-skills-md/tests/cli-commands.test.ts +0 -1423
  83. package/packages/opencode-agent-skills-md/tests/e2e/startup-smoke.test.ts +0 -66
  84. package/packages/opencode-agent-skills-md/tests/fixtures/skills/home/.claude/skills/claude-user-only-skill/SKILL.md +0 -8
  85. package/packages/opencode-agent-skills-md/tests/fixtures/skills/home/.config/opencode/skills/shared-skill/SKILL.md +0 -8
  86. package/packages/opencode-agent-skills-md/tests/fixtures/skills/home/.config/opencode/skills/user-only-skill/SKILL.md +0 -8
  87. package/packages/opencode-agent-skills-md/tests/fixtures/skills/project/.claude/skills/claude-project-only-skill/SKILL.md +0 -8
  88. package/packages/opencode-agent-skills-md/tests/fixtures/skills/project/.opencode/skills/go-tester/SKILL.md +0 -12
  89. package/packages/opencode-agent-skills-md/tests/fixtures/skills/project/.opencode/skills/nested/team/nested-skill/SKILL.md +0 -8
  90. package/packages/opencode-agent-skills-md/tests/fixtures/skills/project/.opencode/skills/rust-tester/SKILL.md +0 -11
  91. package/packages/opencode-agent-skills-md/tests/fixtures/skills/project/.opencode/skills/scripted-skill/SKILL.md +0 -8
  92. package/packages/opencode-agent-skills-md/tests/fixtures/skills/project/.opencode/skills/scripted-skill/bin/echo.sh +0 -2
  93. package/packages/opencode-agent-skills-md/tests/fixtures/skills/project/.opencode/skills/scripted-skill/docs/reference.md +0 -1
  94. package/packages/opencode-agent-skills-md/tests/fixtures/skills/project/.opencode/skills/shared-skill/SKILL.md +0 -8
  95. package/packages/opencode-agent-skills-md/tests/fixtures/skills/project/.opencode/skills/using-superpowers/SKILL.md +0 -8
  96. package/packages/opencode-agent-skills-md/tests/integration/helpers/mock-opencode.ts +0 -114
  97. package/packages/opencode-agent-skills-md/tests/integration/plugin.test.ts +0 -316
  98. package/packages/opencode-agent-skills-md/tests/integration/skill-discovery.test.ts +0 -315
  99. package/packages/opencode-agent-skills-md/tests/opencode/host.test.ts +0 -179
  100. package/packages/opencode-agent-skills-md/tests/opencode/plugin.test.ts +0 -551
  101. package/packages/opencode-agent-skills-md/tests/opencode/subpath.test.ts +0 -66
  102. package/packages/opencode-agent-skills-md/tests/opencode/tools.test.ts +0 -213
  103. package/packages/opencode-agent-skills-md/tests/package-boundary.test.ts +0 -345
  104. package/packages/opencode-agent-skills-md/tests/tools-security.test.ts +0 -72
  105. package/packages/opencode-agent-skills-md/tsconfig.build.json +0 -11
  106. package/packages/opencode-agent-skills-md/tsconfig.json +0 -10
  107. package/plans/001-ci-gate.md +0 -177
  108. package/plans/002-is-path-safe.md +0 -243
  109. package/plans/003-escape-prompts.md +0 -310
  110. package/plans/004-test-security-paths.md +0 -228
  111. package/plans/005-stop-swallowing-errors.md +0 -246
  112. package/plans/006-preserve-jsonc-commas.md +0 -144
  113. package/plans/007-write-before-purge.md +0 -144
  114. package/plans/008-reuse-walkdir-for-list-skill-files.md +0 -164
  115. package/plans/README.md +0 -43
  116. package/pnpm-workspace.yaml +0 -6
  117. package/tests/workspace.test.ts +0 -367
  118. package/tsconfig.json +0 -15
  119. /package/{packages/opencode-agent-skills-md/src → src}/cli/config.ts +0 -0
  120. /package/{packages/opencode-agent-skills-md/src → src}/cli/install.ts +0 -0
  121. /package/{packages/opencode-agent-skills-md/src → src}/cli/main.ts +0 -0
  122. /package/{packages/opencode-agent-skills-md/src → src}/cli/real-fs.ts +0 -0
  123. /package/{packages/opencode-agent-skills-md/src → src}/cli/status.ts +0 -0
  124. /package/{packages/opencode-agent-skills-md/src → src}/cli/uninstall.ts +0 -0
  125. /package/{packages/opencode-agent-skills-md/src → src}/host.ts +0 -0
  126. /package/{packages/opencode-agent-skills-md/src → src}/index.ts +0 -0
  127. /package/{packages/opencode-agent-skills-md/src → src}/plugin.ts +0 -0
  128. /package/{packages/opencode-agent-skills-md/src → src}/sdk.ts +0 -0
  129. /package/{packages/opencode-agent-skills-md/src → src}/tools.ts +0 -0
@@ -1,14 +0,0 @@
1
- #!/bin/bash
2
- # Echo back arguments to test run_skill_script with args
3
-
4
- echo "Arguments received: $@"
5
- echo "Number of arguments: $#"
6
-
7
- if [ $# -eq 0 ]; then
8
- echo "No arguments provided."
9
- else
10
- echo "Arguments breakdown:"
11
- for i in "$@"; do
12
- echo " - $i"
13
- done
14
- fi
@@ -1,6 +0,0 @@
1
- #!/bin/bash
2
- # Simple greeting script to test run_skill_script
3
-
4
- echo "Hello from test-skill!"
5
- echo "Script executed successfully."
6
- echo "Current directory: $(pwd)"
package/AGENTS.md DELETED
@@ -1,43 +0,0 @@
1
- # Agent Guidelines
2
-
3
- ## Commands
4
- - **Package manager:** pnpm.
5
- - **Install:** `pnpm install`
6
- - **Test:** `pnpm test` (runs `pnpm -r --no-bail test` for both packages, then the workspace contract test if all packages pass)
7
- - **Workspace contract test only:** `pnpm run test:workspace` (runs `node --import tsx --test tests/workspace.test.ts`)
8
- - **Single test file:** `pnpm -F opencode-agent-skills-md-core exec node --import tsx --test tests/<file>.test.ts` (or any file inside a package's `tests/`)
9
- - **Typecheck:** `pnpm run typecheck` (delegates to `pnpm -r run typecheck`)
10
- - **Build:** `pnpm run build` (delegates to `pnpm -r --workspace-concurrency=1 run build`)
11
-
12
- ## Code Style
13
- - TypeScript is strict (`noUncheckedIndexedAccess` is on); check indexed access before using it.
14
- - ESM only; use `import`/`export` and `node:` builtins.
15
- - Runtime validation is manual (no Zod dependency).
16
- - Keep public functions documented with JSDoc when they are part of the plugin surface.
17
- - Prefer graceful fallbacks over hard failures for optional discovery and compaction hooks.
18
- - Validate user-supplied paths before reading files outside a skill root.
19
-
20
- ## Repo Structure
21
- This is a pnpm workspace with two packages:
22
- - `packages/core/src/` — the portable, host-agnostic skills engine (`opencode-agent-skills-md-core`). Discovery, parsing, search, and the `SkillHostClient` / `SkillHostSession` boundary contracts.
23
- - `packages/opencode-agent-skills-md/src/` — the OpenCode plugin adapter (`opencode-agent-skills-md`). The four skill tools, the OpenCode host implementation, and the plugin factory.
24
- - Per-package tests live inside `packages/<pkg>/tests/`.
25
- - The repo root is a private workspace manifest (`package.json`) with no source of its own; legacy `src/`, root `tests/`, root `rolldown.config.js`, and root `tsconfig.build.json` were removed in favor of the per-package locations.
26
-
27
- ## Skill Behavior
28
- - Discovery order is `.opencode/skills/`, `.claude/skills/`, `~/.config/opencode/skills/`, then `~/.claude/skills/`.
29
- - First match wins; duplicate skill names are ignored.
30
- - `use_skill` injects `SKILL.md` into context.
31
- - `read_skill_file` only reads inside the selected skill directory.
32
- - `run_skill_script` only runs executable files.
33
- - `OPENCODE_AGENT_SKILLS_SUPERPOWERS_MODE=true` enables the optional Superpowers bootstrap.
34
-
35
- ## Task Tracking
36
- - Use **bd (beads)** for all issue/task tracking; do not create markdown TODO lists.
37
- - Commit `.beads/issues.jsonl` with code changes when issue state changes.
38
- - Run `bd sync` at the end of work sessions.
39
- - `.github/copilot-instructions.md` mirrors the bd workflow and is the repo-local source of truth.
40
-
41
- ## Verification
42
- - Prefer `pnpm run typecheck` before `pnpm test` when you need a quick smoke check.
43
- - Keep docs aligned with the actual repo workflow; Bun references are stale and should not be reintroduced.
package/CHANGELOG.md DELETED
@@ -1,178 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project attempts to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- <!--
9
- ## [${version}]
10
- ### Added - for new features
11
- ### Changed - for changes in existing functionality
12
- ### Deprecated - for soon-to-be removed features
13
- ### Removed - for now removed features
14
- ### Fixed - for any bug fixes
15
- ### Security - in case of vulnerabilities
16
- [${version}]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v${version}
17
- -->
18
-
19
- ## [Unreleased]
20
-
21
- ### Changed
22
-
23
- - **Workspace split**: the repository now publishes two packages from a single pnpm workspace. The reusable, host-agnostic skills engine lives at [`opencode-agent-skills-md-core`](packages/core) and the OpenCode plugin adapter lives at [`opencode-agent-skills-md`](packages/opencode-agent-skills-md). The plugin package now consumes the core engine through a workspace dependency instead of relative source imports. The repo root is a private workspace manifest whose `build`, `test`, and `typecheck` scripts delegate to both packages via `pnpm -r`.
24
-
25
- ### Added
26
-
27
- - The `opencode-agent-skills-md-core` package is published as a standalone ESM module so custom harnesses, CLIs, and test fixtures can embed the skills engine without pulling `@opencode-ai/plugin`. Consumers implement the `SkillHostClient` / `SkillHostSession` boundary contracts declared in `packages/core/src/types.ts` against their own host.
28
-
29
- ### Removed
30
-
31
- - The legacy `opencode-agent-skills-md/core` subpath export is gone. Replace imports of `opencode-agent-skills-md/core` with `opencode-agent-skills-md-core`. The legacy root `src/`, root `tests/`, root `rolldown.config.js`, and root `tsconfig.build.json` have also been removed; each now lives inside the owning workspace package.
32
-
33
- ## [0.7.0]
34
-
35
- ### Added
36
-
37
- - Added `HF_ENDPOINT` support for configuring a Hugging Face mirror for embedding model downloads ([#38](https://github.com/MetalbolicX/opencode-agent-skills-md/pull/38), thanks [@pablon](https://github.com/pablon)).
38
-
39
- ## [0.6.5]
40
-
41
- ### Fixed
42
-
43
- - Fixed crash on macOS ARM64 (Apple Silicon) caused by `onnxruntime-node@1.21.0` segfault regression by pinning to 1.20.1 ([#31](https://github.com/MetalbolicX/opencode-agent-skills-md/issues/31), [microsoft/onnxruntime#24096](https://github.com/microsoft/onnxruntime/issues/24096))
44
-
45
- ## [0.6.4]
46
-
47
- ### Fixed
48
-
49
- - Fixed YAML frontmatter parsing for skills with multi-line descriptions (block scalar `|` and `>` syntax) by replacing custom parser with the `yaml` library
50
- - Added support for Claude's plugin v2 format in `installed_plugins.json`, which uses an array of installations per plugin instead of a single object
51
-
52
- ### Changed
53
-
54
- - Claude Code plugin cache discovery now handles the new nested directory structure (`cache/<marketplace>/<plugin>/<version>/skills/`)
55
-
56
- ## [0.6.3]
57
-
58
- ### Changed
59
-
60
- - Improved skill evaluation prompt to hopefully prevent models from announcing "no skill required" style messages to users (who cannot see the hidden evaluation prompt)
61
-
62
- ## [0.6.2]
63
-
64
- ### Fixed
65
-
66
- - Skill validation now allows directory names to differ from the `name` in SKILL.md frontmatter. The frontmatter `name` is the canonical identifier, while directory names are for organization only. This aligns with the Anthropic Agent Skills spec.
67
-
68
- ## [0.6.1]
69
-
70
- ### Changed
71
-
72
- - Dynamic skill suggestions now track loaded skills per session and avoid re-suggesting already-loaded skills, reducing redundant prompts and context usage
73
-
74
- ## [0.6.0]
75
-
76
- ### Added
77
-
78
- - Semantic skill matching: after the initial skills list injection, subsequent messages are matched against skill descriptions using local embeddings
79
- - Added `@huggingface/transformers` dependency for local embedding generation (quantized all-MiniLM-L6-v2)
80
- - When a message matches available skills, injects a 3-step evaluation prompt (EVALUATE → DECIDE → ACTIVATE) to encourage skill loading (inspired by [@spences10](https://github.com/spences10)'s [blog post](https://scottspence.com/posts/how-to-make-claude-code-skills-activate-reliably))
81
- - Disk-cached embeddings for low-latency matching (~/.cache/opencode-agent-skills-md/)
82
- - Session cleanup on `session.deleted` event
83
-
84
- ## [0.5.0]
85
-
86
- ### Added
87
-
88
- - Added "Did you mean..." fuzzy matching suggestions when skill or script names are not found in all tools (`use_skill`, `read_skill_file`, `run_skill_script`, `get_available_skills`)
89
-
90
- ### Changed
91
-
92
- - **BREAKING**: Renamed `find_skills` tool to `get_available_skills` for clearer intent
93
- - **Internal**: Reorganized codebase into separate modules (`claude.ts`, `skills.ts`, `tools.ts`, `utils.ts`, `superpowers.ts`) for better maintainability
94
- - **Internal**: Improved code quality by removing AI-generated comments and unnecessary code
95
-
96
- ## [0.4.1]
97
-
98
- ### Changed
99
-
100
- - Installation method now uses npm package via OpenCode config instead of git clone + symlink
101
-
102
- ### Removed
103
-
104
- - Removed `INSTALL.md` (no longer needed with simplified installation)
105
-
106
- ## [0.4.0]
107
-
108
- ### Changed
109
-
110
- - Script discovery now recursively searches the entire skill directory (max depth 10) instead of only the root and `scripts/` subdirectory
111
- - Scripts are now identified by relative path (e.g., `tools/build.sh`) instead of base name
112
- - Renamed `skill_name` parameter to `skill` in `read_skill_file`, `run_skill_script`, and `use_skill` tools
113
- - Renamed `script_name` parameter to `script` in `run_skill_script` tool
114
-
115
- ## [0.3.3]
116
-
117
- ### Fixed
118
-
119
- - Fixed file and directory detection to properly handle symlinks by using `fs.stat`
120
-
121
- ## [0.3.2]
122
-
123
- ### Fixed
124
-
125
- - Preserve agent mode when injecting synthetic messages on session start
126
-
127
- ## [0.3.1]
128
-
129
- ### Fixed
130
-
131
- - Fixed unintended model switching when using skill tools by explicitly passing the current model during `noReply` operations (workaround for opencode issue #4475)
132
-
133
- ## [0.3.0]
134
-
135
- ### Added
136
-
137
- - Added file listing to `use_skill` output
138
-
139
- ## [0.2.0]
140
-
141
- ### Added
142
-
143
- - Added support for superpowers mode
144
- - Added release attestations
145
-
146
- ## [0.1.0]
147
-
148
- ### Added
149
-
150
- - Added `use_skill` tool to load skill content into context
151
- - Added `read_skill_file` tool to read supporting files from skill directories
152
- - Added `run_skill_script` tool to execute scripts from skill directories
153
- - Added `find_skills` tool to search and list available skills
154
- - Added multi-location skill discovery (project, user, and Claude-compatible locations)
155
- - Added Anthropic Agent Skills Spec v1.0 compliant frontmatter validation
156
- - Added automatic skills list injection on session start and after context compaction
157
-
158
- ### New Contributors
159
-
160
- - Josh Thomas <josh@joshthomas.dev> (maintainer)
161
-
162
- [unreleased]: https://github.com/MetalbolicX/opencode-agent-skills-md/compare/v0.7.0...HEAD
163
- [0.1.0]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.1.0
164
- [0.2.0]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.2.0
165
- [0.3.0]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.3.0
166
- [0.3.1]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.3.1
167
- [0.3.2]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.3.2
168
- [0.3.3]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.3.3
169
- [0.4.0]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.4.0
170
- [0.4.1]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.4.1
171
- [0.5.0]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.5.0
172
- [0.6.0]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.6.0
173
- [0.6.1]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.6.1
174
- [0.6.2]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.6.2
175
- [0.6.3]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.6.3
176
- [0.6.4]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.6.4
177
- [0.6.5]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.6.5
178
- [0.7.0]: https://github.com/MetalbolicX/opencode-agent-skills-md/releases/tag/v0.7.0
package/Justfile DELETED
@@ -1,39 +0,0 @@
1
- set dotenv-load := true
2
- set unstable := true
3
-
4
- [private]
5
- default:
6
- @just --list --list-submodules
7
-
8
- [private]
9
- fmt:
10
- @just --fmt
11
-
12
- # Build both workspace packages (core engine + OpenCode plugin)
13
- build:
14
- pnpm run build
15
-
16
- # Install dev plugin locally (project-scoped stub that re-exports the built bundle)
17
- install: build
18
- mkdir -p .opencode/plugins
19
- printf 'export { SkillsPlugin as default, SkillsPlugin } from "../../packages/opencode-agent-skills-md/dist/opencode/index.js";\n' > .opencode/plugins/skills.js
20
-
21
- # Uninstall local plugin copy
22
- uninstall:
23
- rm -f .opencode/plugins/skills.js
24
-
25
- # Check if local plugin is installed
26
- status:
27
- @ls -la .opencode/plugins/skills.js 2>/dev/null || echo "Not installed"
28
-
29
- # Run the full test suite (both packages + workspace contract test)
30
- test:
31
- pnpm test
32
-
33
- # Run the workspace contract test in isolation
34
- test-workspace:
35
- pnpm run test:workspace
36
-
37
- # Typecheck both workspace packages
38
- typecheck:
39
- pnpm run typecheck
package/README.md DELETED
@@ -1,220 +0,0 @@
1
- # opencode-agent-skills-md
2
-
3
- <p align="center">
4
- <a href="https://github.com/MetalbolicX/opencode-agent-skills-md/actions/workflows/release.yml"><img alt="release" src="https://img.shields.io/github/actions/workflow/status/MetalbolicX/opencode-agent-skills-md/release.yml?style=flat-square&logo=githubactions&label=release" /></a>
5
- <a href="https://www.npmjs.com/package/opencode-agent-skills-md"><img alt="npm" src="https://img.shields.io/npm/v/opencode-agent-skills-md?style=flat-square&logo=npm" /></a>
6
- <a href="LICENSE"><img alt="license" src="https://img.shields.io/github/license/MetalbolicX/opencode-agent-skills-md?style=flat-square" /></a>
7
- </p>
8
-
9
- <p align="center">Reusable Agent Skills engine plus an OpenCode plugin adapter, distributed as two workspace packages.</p>
10
-
11
- ## Table of Contents
12
-
13
- - [Description](#description)
14
- - [Which Package?](#which-package)
15
- - [Features](#features)
16
- - [Installation](#installation)
17
- - [Usage](#usage)
18
- - [How it Works](#how-it-works)
19
- - [Examples](#examples)
20
- - [Contributing](#contributing)
21
- - [License](#license)
22
-
23
- ## Description
24
-
25
- This repo publishes two packages:
26
-
27
- | Package | Purpose |
28
- |---------|---------|
29
- | [`opencode-agent-skills-md`](https://www.npmjs.com/package/opencode-agent-skills-md) | OpenCode plugin — the four skill tools (`use_skill`, `read_skill_file`, `run_skill_script`, `get_available_skills`) and the OpenCode host adapter. |
30
- | [`opencode-agent-skills-md-core`](packages/core) | Portable, host-agnostic skills engine: discovery, parsing, search, and the `SkillHostClient` / `SkillHostSession` boundary contracts. Zero dependency on `@opencode-ai/plugin`. |
31
-
32
- The core engine is the reusable engine; the OpenCode plugin is one concrete adapter built on top of it.
33
-
34
- ## Which Package?
35
-
36
- Pick the package that matches your harness:
37
-
38
- - **You use OpenCode** → install [`opencode-agent-skills-md`](https://www.npmjs.com/package/opencode-agent-skills-md). It already implements the `SkillHostClient` boundary against the OpenCode SDK and ships the four tools ready to load.
39
- - **You build a custom harness, CLI, or test fixture** → install [`opencode-agent-skills-md-core`](packages/core). It is a standalone ESM package whose runtime dependencies exclude `@opencode-ai/plugin`. You provide your own `SkillHostClient` implementation and pass it to the tool factories of your choice.
40
-
41
- Both packages live in this repo as a pnpm workspace. From the repo root, `pnpm install` wires them together via the workspace link so the OpenCode plugin can resolve `opencode-agent-skills-md-core` by name during development.
42
-
43
- ## Features
44
-
45
- - **Standardized Skill Discovery**: Finds skills from project and user locations, supporting both OpenCode and Claude skill directory layouts.
46
- - **Context Injection**: Loads `SKILL.md` content directly into the context window as synthetic, non-reply messages.
47
- - **Smart Keyword Matching**: Automatically monitors messages and uses lightweight keyword matching to invisibly prompt the agent to use relevant skills.
48
- - **Compaction Resilient**: Re-injects the list of loaded skills after session compaction events to ensure they remain available in long-running sessions.
49
- - **Script Execution**: Recursively finds and executes scripts (files with the executable bit set) within skill directories.
50
- - **Superpowers Mode**: Optional integration to automatically bootstrap the `using-superpowers` workflow.
51
- - **Reusable Engine**: The core package is host-agnostic — write a `SkillHostClient` for your harness and reuse the entire skills engine without pulling the OpenCode SDK.
52
-
53
- ## Installation
54
-
55
- ### Quick install (recommended)
56
-
57
- ```bash
58
- npx opencode-agent-skills-md install
59
- ```
60
-
61
- This registers the plugin in your global OpenCode config and verifies the installation. Restart OpenCode to activate.
62
-
63
- ### CLI commands
64
-
65
- After installing, the following commands are available:
66
-
67
- - `oas install` — register the plugin in the global OpenCode config
68
- - `oas uninstall` — remove the plugin from the global OpenCode config
69
- - `oas status` — check whether the plugin is currently installed
70
- - `oas doctor` — validate the OpenCode configuration health
71
-
72
- ### From npm (alternative)
73
-
74
- ```bash
75
- npm install -g opencode-agent-skills-md
76
- ```
77
-
78
- Then add the plugin to `~/.config/opencode/opencode.json`:
79
-
80
- ```json
81
- {
82
- "plugin": ["opencode-agent-skills-md"]
83
- }
84
- ```
85
-
86
- To pin a specific version:
87
-
88
- ```json
89
- {
90
- "plugin": ["opencode-agent-skills-md@0.7.0"]
91
- }
92
- ```
93
-
94
- ### Manual configuration (fallback)
95
-
96
- If you prefer not to use the CLI, add the plugin entry manually to `~/.config/opencode/opencode.json`:
97
-
98
- ```json
99
- {
100
- "plugin": ["opencode-agent-skills-md"]
101
- }
102
- ```
103
-
104
- Restart OpenCode after updating the config.
105
-
106
- ### Custom harness (standalone engine)
107
-
108
- Install the core engine and implement `SkillHostClient` against your own host:
109
-
110
- ```bash
111
- pnpm add opencode-agent-skills-md-core
112
- ```
113
-
114
- ```ts
115
- import {
116
- discoverAllSkills,
117
- parseSkillFile,
118
- resolveSkill,
119
- type Skill,
120
- type SkillHostClient,
121
- type SkillHostSession,
122
- } from "opencode-agent-skills-md-core";
123
- ```
124
-
125
- The core package has zero runtime dependency on `@opencode-ai/plugin`, so it is the right entry point for custom harnesses, CLIs, and test fixtures. Implement the `SkillHostClient` interface declared in `packages/core/src/types.ts` and pass an instance to the tool factories of your choice.
126
-
127
- ### Local development
128
-
129
- ```bash
130
- git clone https://github.com/MetalbolicX/opencode-agent-skills-md
131
- cd opencode-agent-skills-md
132
- pnpm install
133
- pnpm run build # builds both packages via `pnpm -r run build`
134
- ```
135
-
136
- The OpenCode plugin bundle is emitted at `packages/opencode-agent-skills-md/dist/opencode/index.js`. Symlink it into your local OpenCode plugin directory:
137
-
138
- ```bash
139
- mkdir -p ~/.config/opencode/plugin
140
- ln -sf "$(pwd)/packages/opencode-agent-skills-md/dist/opencode/index.js" ~/.config/opencode/plugin/skills.ts
141
- ```
142
-
143
- ## Usage
144
-
145
- ### Skill Discovery Order
146
-
147
- The plugin discovers skills from these locations, in priority order (first match wins, preventing duplicates):
148
-
149
- 1. `.opencode/skills/` (Project - OpenCode)
150
- 2. `.claude/skills/` (Project - Claude)
151
- 3. `~/.config/opencode/skills/` (User - OpenCode)
152
- 4. `~/.claude/skills/` (User - Claude)
153
-
154
- ### Tools
155
-
156
- Once loaded, use the tools directly from OpenCode:
157
-
158
- | Tool | Description |
159
- |------|-------------|
160
- | `use_skill` | Load a skill's `SKILL.md` into context. |
161
- | `read_skill_file` | Read a file from a skill directory (e.g., `references/rules.md`). |
162
- | `run_skill_script` | Execute a script from a skill directory. The script must be executable (`chmod +x`). |
163
- | `get_available_skills` | List available skills, optionally filtered by an ad-hoc query string. |
164
-
165
- ### Superpowers Integration
166
-
167
- If you have the [Superpowers](https://github.com/obra/superpowers) skill installed, you can automatically inject its bootstrap prompt on session start:
168
-
169
- ```bash
170
- export OPENCODE_AGENT_SKILLS_SUPERPOWERS_MODE=true
171
- opencode
172
- ```
173
-
174
- ## How it Works
175
-
176
- 1. **Session Initialization**: On the first message, a complete list of discovered skills is injected into the context via `<available-skills>`.
177
- 2. **Invisible Evaluation**: For subsequent messages, user text is tokenized and matched against skill names/descriptions. Matches trigger a hidden `<skill-evaluation-required>` block prompting the agent to invoke `use_skill` if appropriate.
178
- 3. **Synthetic Injection**: Tool outputs are injected using `synthetic: true` and `noReply: true`, meaning they do not count as user messages and remain quietly in the context window.
179
- 4. **Script Safety**: File reads (`read_skill_file`) strictly prevent path traversal outside the skill's root directory. Scripts (`run_skill_script`) skip common heavy directories like `node_modules` and `.git` and only execute files with the executable bit set.
180
-
181
- ## Examples
182
-
183
- Load a skill into context:
184
- ```text
185
- use_skill("brainstorming")
186
- ```
187
-
188
- Read a supporting file from a skill:
189
- ```text
190
- read_skill_file("brainstorming", "references/transformation-rules.md")
191
- ```
192
-
193
- Run a script from a skill directory:
194
- ```text
195
- run_skill_script("my-skill", "scripts/build.sh", ["--dry-run"])
196
- ```
197
-
198
- List matching skills:
199
- ```text
200
- get_available_skills({ query: "refactor" })
201
- ```
202
-
203
- ## Contributing
204
-
205
- Contributions are welcome. The codebase uses TypeScript and Rolldown for bundling. Two workspace packages live in this repo:
206
-
207
- - `packages/core/` — the portable skills engine.
208
- - `packages/opencode-agent-skills-md/` — the OpenCode plugin.
209
-
210
- Workspace commands at the repo root (`pnpm run build`, `pnpm test`, `pnpm run typecheck`) delegate to both packages via `pnpm -r`.
211
-
212
- Please run the following before opening a pull request:
213
- ```bash
214
- pnpm run typecheck
215
- pnpm test
216
- ```
217
-
218
- ## License
219
-
220
- MIT. See the [LICENSE](LICENSE) file for details.
@@ -1,74 +0,0 @@
1
- # Core Decoupling Specification
2
-
3
- ## Purpose
4
-
5
- This spec defines the boundary between the portable core skills engine and the OpenCode-specific adapter in the `opencode-agent-skills-md` package. It guarantees that the core is reusable by any host while OpenCode users see no behavior change. This domain is introduced by the `skills-core-decouple` change; there is no prior baseline to delta against, so this file is the initial full definition.
6
-
7
- ## Requirements
8
-
9
- ### Requirement: Core Module Independence (R1)
10
-
11
- The `src/core/**` module graph SHALL contain zero runtime imports from `@opencode-ai/plugin`. A static import walk (AST or regex over the compiled dependency graph of `src/core/**`) SHALL fail the build if any such import is detected.
12
-
13
- ### Requirement: Boundary Interface Location (R2)
14
-
15
- The interfaces `SkillHostClient` and `SkillHostSession` SHALL be declared in `src/core/types.ts`. The concrete OpenCode implementation of those interfaces SHALL exist only in `src/opencode/host.ts`. No other module SHALL contain a concrete implementation of either interface.
16
-
17
- ### Requirement: Backward-Compatible Root Export (R3)
18
-
19
- Importing `opencode-agent-skills-md` (the package root) SHALL return the OpenCode plugin with the same shape and behavior as before this change. A smoke test that loads the package and resolves the four tool names (`use_skill`, `read_skill_file`, `run_skill_script`, `get_available_skills`) SHALL pass.
20
-
21
- ### Requirement: Framework-Agnostic Subpath Export (R4)
22
-
23
- Importing `opencode-agent-skills-md/core` SHALL resolve to the core modules only. A smoke import of the subpath SHALL NOT trigger any side effect, top-level await, or transitive import from `@opencode-ai/plugin`.
24
-
25
- ### Requirement: Discovery Semantics Preservation (R5)
26
-
27
- When the OpenCode adapter delegates to the core's `discoverAllSkills()`, the adapter SHALL observe the same four-location priority and first-match-wins semantics defined by the existing skill behavior. An integration test that mirrors `tests/integration/*` SHALL pass against the new boundary.
28
-
29
- ### Requirement: Public Surface Freeze (R6)
30
-
31
- The four tool names, their parameter shapes, and their user-visible error messages SHALL remain unchanged. Existing tests under `tests/integration/*` and `tests/e2e/*` SHALL pass without modification.
32
-
33
- ## Scenarios
34
-
35
- ### Scenario: core is decoupled from the OpenCode SDK
36
-
37
- - GIVEN the `src/core/**` module graph is fully composed
38
- - WHEN a static import walk scans every file in that graph for `from "@opencode-ai/plugin"`
39
- - THEN zero matches are reported
40
- - AND the test `tests/core/agnostic.test.ts` passes
41
-
42
- ### Scenario: opencode host is the only concrete implementation
43
-
44
- - GIVEN the interfaces `SkillHostClient` and `SkillHostSession` exist in `src/core/types.ts`
45
- - WHEN the codebase is searched for classes or factories that implement either interface
46
- - THEN exactly one match exists, located in `src/opencode/host.ts`
47
-
48
- ### Scenario: root export still loads the OpenCode plugin
49
-
50
- - GIVEN a consumer imports the package via its root export
51
- - WHEN the consumer resolves the four tool names from the returned plugin object
52
- - THEN all four tool names (`use_skill`, `read_skill_file`, `run_skill_script`, `get_available_skills`) are present
53
- - AND the test-skill load assertion in `tests/integration/startup-smoke.test.ts` continues to pass
54
-
55
- ### Scenario: subpath export does not pull in the OpenCode SDK
56
-
57
- - GIVEN a consumer imports `opencode-agent-skills-md/core` in a fresh process
58
- - WHEN the import resolves and the module graph is recorded
59
- - THEN no module under `node_modules/@opencode-ai/plugin` appears in the resolved graph
60
- - AND no side effect from the SDK runs at import time
61
-
62
- ### Scenario: discovery priority and first-match-wins are preserved
63
-
64
- - GIVEN skill fixtures exist under `.opencode/skills/`, `.claude/skills/`, `~/.config/opencode/skills/`, and `~/.claude/skills/`
65
- - WHEN the OpenCode adapter calls `discoverAllSkills()`
66
- - THEN the returned list follows the four-location priority
67
- - AND duplicate skill names resolve to the first matching location
68
- - AND the new integration test in `tests/core/` passes
69
-
70
- ### Scenario: public tool surface is unchanged
71
-
72
- - GIVEN the refactor is complete and `pnpm run typecheck` is clean
73
- - WHEN `pnpm test` runs the existing `tests/integration/*` and `tests/e2e/*` suites
74
- - THEN all existing assertions on tool names, parameter shapes, and error messages continue to pass without modification
@@ -1,64 +0,0 @@
1
- # Tasks: Skills Core Decouple
2
-
3
- ## Review Workload Forecast
4
-
5
- | Field | Value |
6
- |-------|-------|
7
- | Estimated changed lines | PR1≈350; PR2≈250; PR3≈150; aggregate≈750 |
8
- | 400-line budget risk | Low per PR |
9
- | Chained PRs recommended | Yes |
10
- | Suggested split | PR1 core-extraction → PR2 opencode-adapter → PR3 subpath-exports |
11
- | Delivery strategy | force-chained |
12
- | Chain strategy | stacked-to-main |
13
-
14
- Decision needed before apply: No
15
- Chained PRs recommended: Yes
16
- Chain strategy: stacked-to-main
17
- 400-line budget risk: Low
18
-
19
- ### Suggested Work Units
20
-
21
- | Unit | Goal | Likely PR | Notes |
22
- |------|------|-----------|-------|
23
- | 1 | Extract portable core with import guard | PR 1 | Base=main; merge after `pnpm run typecheck` + `pnpm test` |
24
- | 2 | Add OpenCode host and thin adapter | PR 2 | Base=main after PR1 merge; keep root behavior unchanged |
25
- | 3 | Publish subpath exports and built smoke tests | PR 3 | Base=main after PR2 merge; verify build + e2e |
26
-
27
- ## Phase 1: PR1 — Core Extraction
28
-
29
- - [x] 1.1 Capture a green baseline with `pnpm run typecheck` and `pnpm test` before moving files.
30
- - [x] 1.2 RED: add `tests/core/agnostic.test.ts` with a static walk over `dist/core/**` for zero `@opencode-ai/plugin` imports.
31
- - [x] 1.3 Move host-agnostic code from `src/utils.ts` and `src/skills.ts` into `src/core/{types,parse,discovery,scripts,match,content}.ts`.
32
- - [x] 1.4 Add `src/core/index.ts`; update `src/utils.ts` and `src/skills.ts` to re-export or consume core without behavior changes.
33
- - [x] 1.5 Update `rolldown.config.js` for a temporary `dist/core` entry while preserving the current plugin build. *(Superseded by PR3 3.2 — multi-entry build emits both `dist/opencode/index.js` and `dist/core/index.js` plus the legacy `dist/plugin.mjs` alias.)*
34
- - [x] 1.6 GREEN gate: `pnpm run typecheck` and `pnpm test` pass with the new core boundary.
35
-
36
- ## Phase 2: PR2 — OpenCode Adapter
37
-
38
- - [x] 2.1 Add `src/opencode/host.ts` as the only concrete `SkillHostClient` and `SkillHostSession` implementation.
39
- - [x] 2.2 Add `src/opencode/tools.ts` and rewrite tool factories to compose core logic through the host.
40
- - [x] 2.3 Move plugin composition to `src/opencode/plugin.ts`; keep `src/plugin.ts` as a thin compatibility shim until PR3.
41
- - [x] 2.4 Move `src/superpowers.ts` to `src/opencode/superpowers.ts` and wire `src/opencode/index.ts` as the adapter entry.
42
- - [x] 2.5 Verify R5/R6 by running `tests/integration/plugin.test.ts` and `tests/e2e/startup-smoke.test.ts` unchanged.
43
- - [x] 2.6 GREEN gate: `pnpm run typecheck` and `pnpm test` pass before merge.
44
-
45
- ## Phase 3: PR3 — Subpath Exports (public surface change)
46
-
47
- - [x] 3.1 Add `exports` map to `package.json` with `.` and `./core` subpaths (each with `types` + `import` + `default` conditions) and point `main` at `dist/opencode/index.js`.
48
- - [x] 3.2 Rewrite `rolldown.config.js` to multi-entry emit `dist/opencode/index.js` and `dist/core/index.js`; add `tsconfig.build.json` for `tsc --emitDeclarationOnly` so `.d.ts` files travel with the JS chunks.
49
- - [x] 3.3 Add `tests/core/subpath.test.ts` — resolves `opencode-agent-skills-md/core` via the package's exports field, asserts the portable API is exported, and walks the built chunk to prove no `@opencode-ai/plugin` reference leaks in.
50
- - [x] 3.4 Add `tests/opencode/subpath.test.ts` — resolves `opencode-agent-skills-md` (root) via the exports field, asserts the default export + `SkillsPlugin` are the same factory function, and proves module load is side-effect safe.
51
- - [x] 3.5 Add `pretest` hook that runs `pnpm run build` first so the subpath tests always run against fresh built artifacts.
52
- - [x] 3.6 Remove `src/plugin.ts` compat shim (now redundant); build entry is `src/opencode/index.ts` directly. A legacy `dist/plugin.mjs` alias is preserved via a third rolldown entry so any downstream consumer still importing the old path keeps working.
53
- - [x] 3.7 Update `README.md` with a "Programmatic subpath exports" section documenting both subpaths, the intended consumer (harness authors), and a code example using the core.
54
- - [x] 3.8 GREEN gate (final): `pnpm run typecheck` + `pnpm test` + `pnpm run build` all green; the new subpath tests pass against the freshly built artifacts.
55
- - [x] 3.9 Update `openspec/changes/skills-core-decouple/tasks.md` to mark all PR3 tasks done and persist the final apply-progress to engram.
56
-
57
- ### PR3 Outcome
58
-
59
- - `pnpm run typecheck` — clean (0 errors)
60
- - `pnpm test` — 42/42 (21 unit + 3 agnostic + 3 core-subpath + 8 opencode-host + 3 opencode-subpath + 3 integration + 1 e2e)
61
- - `pnpm run build` — emits `dist/opencode/{index.js,index.d.ts,...}`, `dist/core/{index.js,index.d.ts,...}`, and the legacy `dist/plugin.mjs` alias
62
- - The `src/opencode/tools.ts` factory consts needed explicit `: ReturnType<typeof tool>` annotations to break a Zod-shape leak in the inferred return type that broke `tsc --emitDeclarationOnly` with TS2883 (non-portable inferred type). Internal change only — no behavior delta, no public API change.
63
- - The `package.json#exports` block needed a `default` condition on each subpath in addition to `import` so Node 24 can resolve the package via self-reference when called from a CJS context (`require.resolve`).
64
- - The integration test (`tests/integration/plugin.test.ts`) and the e2e test (`tests/e2e/startup-smoke.test.ts`) had their import targets updated to the new entry points (`src/opencode` and `dist/opencode/index.js` respectively).