opencode-knowledge-work 0.1.0 → 0.1.1
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/index.ts +14 -15
- package/package.json +2 -4
package/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { define } from "@opencode-ai/plugin/v2/promise"
|
|
2
1
|
import { existsSync, readFileSync, readdirSync } from "node:fs"
|
|
3
2
|
import { basename, dirname, join, resolve } from "node:path"
|
|
4
3
|
import { fileURLToPath } from "node:url"
|
|
@@ -7,11 +6,12 @@ const CONTENT = resolve(dirname(fileURLToPath(import.meta.url)), "content")
|
|
|
7
6
|
|
|
8
7
|
type SkillEntry = { id: string; name: string; description: string; path: string; content: string }
|
|
9
8
|
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
type
|
|
9
|
+
// OpenCode's Plugin.define is `(plugin) => plugin`, so declaring the shape
|
|
10
|
+
// locally removes the only dependency. That matters: a dependency-free package
|
|
11
|
+
// loads from a bare clone or unpacked tarball, where OpenCode does not install
|
|
12
|
+
// deps for local-directory plugin specs.
|
|
13
|
+
type PluginContext = {
|
|
14
|
+
options: Record<string, unknown>
|
|
15
15
|
app: { log: { warn(message: string): void } }
|
|
16
16
|
skill: { transform(cb: (editor: { add(skill: SkillEntry): void }) => void): Promise<unknown> }
|
|
17
17
|
}
|
|
@@ -25,7 +25,7 @@ function available(): string[] {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Only `name` and `description` matter here, and both are single-line in every
|
|
28
|
-
// vendored SKILL.md. A
|
|
28
|
+
// vendored SKILL.md. A YAML parser would be a dependency for nothing.
|
|
29
29
|
function frontmatter(raw: string): { name?: string; description?: string } {
|
|
30
30
|
const match = raw.match(/^---\r?\n([\s\S]*?)\r?\n---/)
|
|
31
31
|
if (!match) return {}
|
|
@@ -37,11 +37,10 @@ function frontmatter(raw: string): { name?: string; description?: string } {
|
|
|
37
37
|
return out
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export default
|
|
40
|
+
export default {
|
|
41
41
|
id: "opencode.knowledge-work",
|
|
42
42
|
|
|
43
|
-
async setup(ctx) {
|
|
44
|
-
const runtime = ctx as unknown as Runtime
|
|
43
|
+
async setup(ctx: PluginContext) {
|
|
45
44
|
const all = available()
|
|
46
45
|
if (all.length === 0) return
|
|
47
46
|
|
|
@@ -55,10 +54,10 @@ export default define({
|
|
|
55
54
|
|
|
56
55
|
const unknown = [...wanted].filter((n) => !all.includes(n))
|
|
57
56
|
if (unknown.length > 0) {
|
|
58
|
-
|
|
57
|
+
ctx.app.log.warn(`opencode-knowledge-work: unknown plugin(s) ${unknown.join(", ")}; available: ${all.join(", ")}`)
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
const entries:
|
|
60
|
+
const entries: SkillEntry[] = []
|
|
62
61
|
for (const plugin of selected) {
|
|
63
62
|
const skillsDir = join(CONTENT, plugin, "skills")
|
|
64
63
|
for (const entry of readdirSync(skillsDir, { withFileTypes: true })) {
|
|
@@ -68,7 +67,7 @@ export default define({
|
|
|
68
67
|
const meta = frontmatter(raw)
|
|
69
68
|
if (!meta.description) continue
|
|
70
69
|
entries.push({
|
|
71
|
-
id: basename(entry.name), //
|
|
70
|
+
id: basename(entry.name), // namespaced by scripts/sync-upstream.ts
|
|
72
71
|
name: meta.name ?? basename(entry.name),
|
|
73
72
|
description: meta.description,
|
|
74
73
|
path: file,
|
|
@@ -77,8 +76,8 @@ export default define({
|
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
await
|
|
79
|
+
await ctx.skill.transform((editor) => {
|
|
81
80
|
for (const skill of entries) editor.add(skill)
|
|
82
81
|
})
|
|
83
82
|
},
|
|
84
|
-
}
|
|
83
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-knowledge-work",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Anthropic's knowledge-work plugin collection, adapted for OpenCode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
|
@@ -23,9 +23,7 @@
|
|
|
23
23
|
"knowledge-work"
|
|
24
24
|
],
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"@opencode-ai/plugin": "^1.18.32"
|
|
28
|
-
},
|
|
26
|
+
"dependencies": {},
|
|
29
27
|
"devDependencies": {
|
|
30
28
|
"@types/node": "^24.12.2",
|
|
31
29
|
"typescript": "^5.8.2"
|