@skillstate/opencode 2.0.2 → 2.0.3
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 +61 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/@skillstate/opencode)
|
|
8
8
|
[](https://www.npmjs.com/package/@skillstate/opencode)
|
|
9
|
-
[](https://github.com/
|
|
10
|
-
[](https://github.com/
|
|
9
|
+
[](https://github.com/vitkuz573/skillstate)
|
|
10
|
+
[](https://github.com/vitkuz573/skillstate/blob/main/LICENSE)
|
|
11
11
|
|
|
12
12
|
</div>
|
|
13
13
|
|
|
@@ -60,6 +60,65 @@ const saved = await adapter.savePluginCode(
|
|
|
60
60
|
);
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
+
## Install into OpenCode (host)
|
|
64
|
+
|
|
65
|
+
Tested end-to-end against OpenCode ≥ 1.17 (`@opencode-ai/plugin` 1.15.x
|
|
66
|
+
hook contracts). Four steps:
|
|
67
|
+
|
|
68
|
+
**1. Generate the plugin file** (one-off, or wire into a build script):
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
// scripts/gen-plugin.mjs (run with: node scripts/gen-plugin.mjs)
|
|
72
|
+
import { OpenCodeAdapter } from '@skillstate/opencode';
|
|
73
|
+
import { writeFileSync } from 'node:fs';
|
|
74
|
+
|
|
75
|
+
const adapter = new OpenCodeAdapter();
|
|
76
|
+
const statePath = '/abs/path/to/.skillstate.json';
|
|
77
|
+
const code = adapter.generatePluginCode(statePath, { maxHistoryMessages: 3 });
|
|
78
|
+
writeFileSync('/abs/path/to/skillstate.plugin.ts', code);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Put the generated `skillstate.plugin.ts` anywhere stable (absolute path is
|
|
82
|
+
safest), e.g. `<project>/.opencode-runtime/skillstate.plugin.ts`.
|
|
83
|
+
|
|
84
|
+
**2. Create the initial state file** (`statePath` from step 1), matching your
|
|
85
|
+
spec schema, e.g. for `INTERCODE_CTF_SPEC`:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"discovered_flags": [],
|
|
90
|
+
"tested_hypotheses": [],
|
|
91
|
+
"active_files": [],
|
|
92
|
+
"working_dir": "/abs/work/dir",
|
|
93
|
+
"cmd_summary": "initialized"
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**3. Register the plugin in `opencode.jsonc`** — add a `file://` entry to the
|
|
98
|
+
`plugin` array (local paths are resolved by OpenCode and imported directly;
|
|
99
|
+
TypeScript is supported because plugins load under Bun):
|
|
100
|
+
|
|
101
|
+
```jsonc
|
|
102
|
+
{
|
|
103
|
+
"plugin": [
|
|
104
|
+
"@ai-sdk/anthropic",
|
|
105
|
+
"file:///abs/path/to/skillstate.plugin.ts"
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**4. Install the SKILL.md** — write `adapter.generateSkillMd(spec, statePath)`
|
|
111
|
+
to `~/.config/opencode/skills/skillstate/SKILL.md` (global) or
|
|
112
|
+
`.opencode/skills/skillstate/SKILL.md` (project). Keep the frontmatter fields
|
|
113
|
+
`name` (must match the folder name) and a one-line `description`; the
|
|
114
|
+
generated frontmatter may need a manual trim to those two fields.
|
|
115
|
+
|
|
116
|
+
Verify with `opencode debug config` (plugin entry shows under `plugin`) and
|
|
117
|
+
`opencode debug skill` (your skill is listed). Hook notes for OpenCode ≥ 1.17:
|
|
118
|
+
`messages.transform` receives `{ info: Message, parts: Part[] }` entries and
|
|
119
|
+
must mutate `output.messages` **in place**; the plugin injects state as a
|
|
120
|
+
synthetic `{ info, parts }` message.
|
|
121
|
+
|
|
63
122
|
## API / Exports
|
|
64
123
|
|
|
65
124
|
Root path `@skillstate/opencode` exports one thing: `OpenCodeAdapter`.
|