agentikit-opencode 0.0.7

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 (2) hide show
  1. package/index.ts +76 -0
  2. package/package.json +37 -0
package/index.ts ADDED
@@ -0,0 +1,76 @@
1
+ import { type Plugin, tool } from "@opencode-ai/plugin"
2
+ import { execFileSync } from "node:child_process"
3
+
4
+ function runCli(args: string[]): string {
5
+ try {
6
+ return execFileSync("agentikit", args, {
7
+ encoding: "utf8",
8
+ timeout: 60_000,
9
+ })
10
+ } catch (error: unknown) {
11
+ const message = error instanceof Error ? error.message : String(error)
12
+ return JSON.stringify({ ok: false, error: message })
13
+ }
14
+ }
15
+
16
+ export const AgentikitPlugin: Plugin = async ({ directory }) => ({
17
+ tool: {
18
+ agentikit_search: tool({
19
+ description: "Search the Agentikit stash for tools, skills, commands, agents, and knowledge.",
20
+ args: {
21
+ query: tool.schema.string().describe("Case-insensitive substring search."),
22
+ type: tool.schema
23
+ .enum(["tool", "skill", "command", "agent", "knowledge", "any"])
24
+ .optional()
25
+ .describe("Optional type filter. Defaults to 'any'."),
26
+ limit: tool.schema.number().optional().describe("Maximum number of hits to return. Defaults to 20."),
27
+ },
28
+ async execute({ query, type, limit }) {
29
+ const args = ["search", query]
30
+ if (type) args.push("--type", type)
31
+ if (limit) args.push("--limit", String(limit))
32
+ return runCli(args)
33
+ },
34
+ }),
35
+ agentikit_open: tool({
36
+ description: "Open a stash asset by ref. For knowledge assets, use view_mode to retrieve specific content (toc, section, lines, frontmatter).",
37
+ args: {
38
+ ref: tool.schema.string().describe("Open reference returned by agentikit_search."),
39
+ view_mode: tool.schema
40
+ .enum(["full", "toc", "frontmatter", "section", "lines"])
41
+ .optional()
42
+ .describe("View mode for knowledge assets. Defaults to 'full'. Ignored for other types."),
43
+ heading: tool.schema.string().optional()
44
+ .describe("Section heading to extract (required when view_mode is 'section')."),
45
+ start_line: tool.schema.number().optional()
46
+ .describe("Start line number, 1-based (for view_mode 'lines')."),
47
+ end_line: tool.schema.number().optional()
48
+ .describe("End line number, 1-based inclusive (for view_mode 'lines')."),
49
+ },
50
+ async execute({ ref, view_mode, heading, start_line, end_line }) {
51
+ const args = ["open", ref]
52
+ if (view_mode) args.push("--view", view_mode)
53
+ if (heading) args.push("--heading", heading)
54
+ if (start_line != null) args.push("--start", String(start_line))
55
+ if (end_line != null) args.push("--end", String(end_line))
56
+ return runCli(args)
57
+ },
58
+ }),
59
+ agentikit_run: tool({
60
+ description: "Run a tool from the Agentikit stash by its openRef. Only tool refs are supported.",
61
+ args: {
62
+ ref: tool.schema.string().describe("Open reference of a tool returned by agentikit_search."),
63
+ },
64
+ async execute({ ref }) {
65
+ return runCli(["run", ref])
66
+ },
67
+ }),
68
+ agentikit_index: tool({
69
+ description: "Build or rebuild the Agentikit search index. Scans stash directories, generates missing .stash.json metadata, and builds a semantic search index.",
70
+ args: {},
71
+ async execute() {
72
+ return runCli(["index"])
73
+ },
74
+ }),
75
+ },
76
+ })
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "agentikit-opencode",
3
+ "version": "0.0.7",
4
+ "type": "module",
5
+ "description": "OpenCode plugin for Agentikit - search, open, and run extension assets via the agentikit CLI.",
6
+ "keywords": [
7
+ "opencode",
8
+ "opencode-ai",
9
+ "opencode-plugin",
10
+ "opencode-extensions",
11
+ "agentikit",
12
+ "ai-agent",
13
+ "developer-tools",
14
+ "plugin"
15
+ ],
16
+ "homepage": "https://github.com/itlackey/agentikit-plugins#readme",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/itlackey/agentikit-plugins.git",
20
+ "directory": "opencode"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/itlackey/agentikit-plugins/issues"
24
+ },
25
+ "license": "CC-BY-4.0",
26
+ "files": [
27
+ "index.ts",
28
+ "README.md"
29
+ ],
30
+ "main": "./index.ts",
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "dependencies": {
35
+ "@opencode-ai/plugin": "^1.2.20"
36
+ }
37
+ }