@weaveio/weave-adapter-opencode 0.0.0-preview-20260708084849
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 +83 -0
- package/dist/adapter.d.ts +218 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/command-templates.d.ts +38 -0
- package/dist/command-templates.d.ts.map +1 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26155 -0
- package/dist/model-resolution.d.ts +112 -0
- package/dist/model-resolution.d.ts.map +1 -0
- package/dist/opencode-client.d.ts +94 -0
- package/dist/opencode-client.d.ts.map +1 -0
- package/dist/plugin.d.ts +184 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +23973 -0
- package/dist/projection-helpers.d.ts +59 -0
- package/dist/projection-helpers.d.ts.map +1 -0
- package/dist/reconcile-agent.d.ts +131 -0
- package/dist/reconcile-agent.d.ts.map +1 -0
- package/dist/run-workflow.d.ts +127 -0
- package/dist/run-workflow.d.ts.map +1 -0
- package/dist/runtime-command-projection.d.ts +365 -0
- package/dist/runtime-command-projection.d.ts.map +1 -0
- package/dist/sdk-types.d.ts +56 -0
- package/dist/sdk-types.d.ts.map +1 -0
- package/dist/skill-discovery.d.ts +73 -0
- package/dist/skill-discovery.d.ts.map +1 -0
- package/dist/start-plan-execution.d.ts +164 -0
- package/dist/start-plan-execution.d.ts.map +1 -0
- package/dist/tool-policy-mapping.d.ts +77 -0
- package/dist/tool-policy-mapping.d.ts.map +1 -0
- package/dist/translate-agent.d.ts +48 -0
- package/dist/translate-agent.d.ts.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @weaveio/weave-adapter-opencode
|
|
2
|
+
|
|
3
|
+
OpenCode adapter for Weave.
|
|
4
|
+
|
|
5
|
+
## Plugin entrypoint
|
|
6
|
+
|
|
7
|
+
When loading this adapter as an OpenCode plugin, use the plugin bundle entrypoint:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"plugin": [
|
|
12
|
+
"@weaveio/weave-adapter-opencode/plugin"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For a direct file URL during local development, point OpenCode at `dist/plugin.js`, not `dist/index.js`:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"plugin": [
|
|
22
|
+
"file:///abs/path/to/packages/adapters/opencode/dist/plugin.js"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Rebuild the package before using a `dist/` file path so the plugin bundle matches the current source:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun run --filter @weaveio/weave-adapter-opencode build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Do **not** use the bare package entry (`@weaveio/weave-adapter-opencode`) or `dist/index.js` as a plugin target. The bare entry is the programmatic barrel and exports non-plugin values in addition to the plugin function, which is incompatible with OpenCode's legacy plugin loader.
|
|
34
|
+
|
|
35
|
+
## Isolated OpenCode validation
|
|
36
|
+
|
|
37
|
+
OpenCode merges global config, project config, explicit config, and plugin directories. `OPENCODE_CONFIG` and `OPENCODE_CONFIG_CONTENT` add config; they do not replace every other source by themselves.
|
|
38
|
+
|
|
39
|
+
To validate this adapter in isolation:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
TMP_HOME="$(mktemp -d)"
|
|
43
|
+
TMP_XDG="$(mktemp -d)"
|
|
44
|
+
|
|
45
|
+
HOME="$TMP_HOME" \
|
|
46
|
+
XDG_CONFIG_HOME="$TMP_XDG" \
|
|
47
|
+
OPENCODE_DISABLE_PROJECT_CONFIG=1 \
|
|
48
|
+
OPENCODE_CONFIG_CONTENT='{
|
|
49
|
+
"$schema": "https://opencode.ai/config.json",
|
|
50
|
+
"plugin": [
|
|
51
|
+
"file:///abs/path/to/packages/adapters/opencode/dist/plugin.js"
|
|
52
|
+
]
|
|
53
|
+
}' \
|
|
54
|
+
opencode debug config
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Use the same environment with `opencode debug info` to verify that the plugin executes, not just that it appears in merged config.
|
|
58
|
+
|
|
59
|
+
## Expected behavior
|
|
60
|
+
|
|
61
|
+
- `opencode debug config` should show the Weave-materialized `agent` map injected by the plugin's `config` hook.
|
|
62
|
+
- `opencode debug info` should show the plugin loading and executing.
|
|
63
|
+
- The resulting OpenCode `agent` entries should reflect the resolved Weave DSL for the loaded `.weave/config.weave` plus builtin Weave agent defaults.
|
|
64
|
+
|
|
65
|
+
## Logging
|
|
66
|
+
|
|
67
|
+
When the plugin runs inside OpenCode, Weave logs are written to a file automatically instead of stdout. Writing structured JSON logs to stdout would surface raw log lines in the OpenCode UI, which is confusing for users.
|
|
68
|
+
|
|
69
|
+
**Default log path**: `.weave/weave.log` under the project directory (the same directory OpenCode passes as `input.directory`).
|
|
70
|
+
|
|
71
|
+
**Override**: set `WEAVE_LOG_FILE=/absolute/path/to/weave.log` in the environment to write logs to a custom path instead.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Use the default path (.weave/weave.log in the project root)
|
|
75
|
+
opencode
|
|
76
|
+
|
|
77
|
+
# Override with a custom path
|
|
78
|
+
WEAVE_LOG_FILE=/tmp/weave-debug.log opencode
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The log file is created automatically when the plugin starts. Parent directories are created if they do not exist. Logs are written synchronously (one write per log line) to ensure lines are visible immediately even if the process is killed.
|
|
82
|
+
|
|
83
|
+
**Non-plugin usage**: when `@weaveio/weave-engine` is used outside the OpenCode plugin path (e.g. in tests or other adapters), logs go to stdout by default unless `WEAVE_LOG_FILE` is set.
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode harness adapter implementation.
|
|
3
|
+
*
|
|
4
|
+
* This module contains the `OpenCodeAdapter` class and its constructor options.
|
|
5
|
+
* It is extracted from `index.ts` to allow `plugin.ts` to import the adapter
|
|
6
|
+
* without creating a circular dependency through the barrel.
|
|
7
|
+
*
|
|
8
|
+
* Boundary rule: this module imports SDK types only through `./sdk-types`.
|
|
9
|
+
* It must not import directly from `@opencode-ai/sdk`.
|
|
10
|
+
*/
|
|
11
|
+
import type { AgentDescriptor, HarnessAdapter, PlanStateProvider, SkillInfo } from "@weaveio/weave-engine";
|
|
12
|
+
import { type ResultAsync } from "neverthrow";
|
|
13
|
+
import { type OpenCodeModelContext } from "./model-resolution.js";
|
|
14
|
+
import type { OpenCodeClientFacade } from "./opencode-client.js";
|
|
15
|
+
import type { OpenCodeAgentConfig } from "./sdk-types.js";
|
|
16
|
+
type OpenCodeAdapterErrorType = "ModelResolutionError" | "TranslateAgentError" | "ReconcileAgentError";
|
|
17
|
+
export declare class OpenCodeAdapterError extends Error {
|
|
18
|
+
readonly type: OpenCodeAdapterErrorType;
|
|
19
|
+
readonly agentName: string;
|
|
20
|
+
readonly cause: unknown;
|
|
21
|
+
constructor(input: {
|
|
22
|
+
type: OpenCodeAdapterErrorType;
|
|
23
|
+
agentName: string;
|
|
24
|
+
message: string;
|
|
25
|
+
cause?: unknown;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Constructor options for `OpenCodeAdapter`.
|
|
30
|
+
*/
|
|
31
|
+
export interface OpenCodeAdapterOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Absolute path to the project root directory.
|
|
34
|
+
*
|
|
35
|
+
* Used to construct the `BunFilesystemPlanStateProvider` so that plan files
|
|
36
|
+
* are resolved relative to the correct project root. Defaults to
|
|
37
|
+
* `Bun.env.PWD ?? "."` when omitted.
|
|
38
|
+
*/
|
|
39
|
+
readonly projectRoot?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Injected OpenCode client facade.
|
|
42
|
+
*
|
|
43
|
+
* Callers (e.g. an OpenCode plugin entry point) provide a pre-constructed
|
|
44
|
+
* `OpenCodeClientFacade` that wraps the SDK client available in the
|
|
45
|
+
* plugin/runtime context. When omitted, the adapter operates in
|
|
46
|
+
* translation-only mode (no live SDK calls).
|
|
47
|
+
*
|
|
48
|
+
* Dependency injection through this option is the primary adapter entry
|
|
49
|
+
* path. No global SDK client state is created or mutated by the adapter.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { createOpencodeClient } from "@opencode-ai/sdk";
|
|
54
|
+
* import { OpenCodeAdapter, SdkOpenCodeClient } from "@weaveio/weave-adapter-opencode";
|
|
55
|
+
*
|
|
56
|
+
* const sdkClient = createOpencodeClient({ directory: projectDir });
|
|
57
|
+
* const adapter = new OpenCodeAdapter({
|
|
58
|
+
* projectRoot: projectDir,
|
|
59
|
+
* client: new SdkOpenCodeClient(sdkClient),
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
readonly client?: OpenCodeClientFacade;
|
|
64
|
+
/**
|
|
65
|
+
* OpenCode model context for model resolution.
|
|
66
|
+
*
|
|
67
|
+
* When provided, `spawnSubagent()` calls `resolveModelForAgent()` with this
|
|
68
|
+
* context to validate model intent before materializing each agent.
|
|
69
|
+
*
|
|
70
|
+
* When omitted, model resolution falls back to the engine's constant
|
|
71
|
+
* fallback model (`DEFAULT_FALLBACK_MODEL`).
|
|
72
|
+
*/
|
|
73
|
+
readonly modelContext?: OpenCodeModelContext;
|
|
74
|
+
/**
|
|
75
|
+
* Harness-provided skill list for `loadAvailableSkills()`.
|
|
76
|
+
*
|
|
77
|
+
* The OpenCode harness (SDK/runtime) is responsible for discovering which
|
|
78
|
+
* skills are available. Callers inject the harness-provided skill list here
|
|
79
|
+
* so the adapter can forward it to the engine without performing any
|
|
80
|
+
* filesystem scanning.
|
|
81
|
+
*
|
|
82
|
+
* When omitted, `loadAvailableSkills()` returns an empty list. The engine
|
|
83
|
+
* will then emit `MissingSkill` errors for any declared skills that cannot
|
|
84
|
+
* be resolved — this is the correct hard-error behavior.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* // In an OpenCode plugin entry point, the SDK provides available skills:
|
|
89
|
+
* const harnessSkills = sdk.listAvailableSkills(); // harness-owned discovery
|
|
90
|
+
* const adapter = new OpenCodeAdapter({
|
|
91
|
+
* availableSkills: harnessSkills.map(s => ({ name: s.name, metadata: s })),
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
readonly availableSkills?: SkillInfo[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* OpenCode harness adapter.
|
|
99
|
+
*
|
|
100
|
+
* Implements the `HarnessAdapter` interface to materialise Weave agent
|
|
101
|
+
* descriptors into a running OpenCode instance via the OpenCode SDK client.
|
|
102
|
+
*
|
|
103
|
+
* When an `OpenCodeClientFacade` is injected, `spawnSubagent()` performs
|
|
104
|
+
* real SDK-backed materialization using the `list → reconcile → create/update`
|
|
105
|
+
* flow in `reconcile-agent.ts`. Without a client the adapter falls back to
|
|
106
|
+
* translation-only mode (no SDK calls are made).
|
|
107
|
+
*
|
|
108
|
+
* `translatedAgents` is retained as a read-only snapshot of the last
|
|
109
|
+
* translated config for each agent. It is populated regardless of whether SDK
|
|
110
|
+
* materialization succeeds, and is available for test inspection and
|
|
111
|
+
* transitional compatibility. It is NOT the primary materialization path.
|
|
112
|
+
*
|
|
113
|
+
* A `BunFilesystemPlanStateProvider` is constructed during `init()` and stored
|
|
114
|
+
* as `this.planStateProvider`. Pass it to any `completeStep` call that uses a
|
|
115
|
+
* `plan_created` or `plan_complete` completion method.
|
|
116
|
+
*/
|
|
117
|
+
export declare class OpenCodeAdapter implements HarnessAdapter {
|
|
118
|
+
/**
|
|
119
|
+
* Read-only snapshot of the last translated OpenCode agent config for each
|
|
120
|
+
* agent, keyed by agent name.
|
|
121
|
+
*
|
|
122
|
+
* Populated by `spawnSubagent()` after successful translation, regardless of
|
|
123
|
+
* whether SDK materialization is attempted. Useful for test inspection and
|
|
124
|
+
* transitional compatibility.
|
|
125
|
+
*
|
|
126
|
+
* The primary materialization path is the SDK-backed `reconcileAgent()` call
|
|
127
|
+
* inside `spawnSubagent()`. This map is a secondary artifact, not the source
|
|
128
|
+
* of truth for what is actually registered in OpenCode.
|
|
129
|
+
*/
|
|
130
|
+
readonly translatedAgents: Map<string, OpenCodeAgentConfig>;
|
|
131
|
+
/**
|
|
132
|
+
* Provider for querying plan file state.
|
|
133
|
+
*
|
|
134
|
+
* Constructed during `init()` using `projectRoot`. Pass to `completeStep`
|
|
135
|
+
* calls that use `plan_created` or `plan_complete` completion methods.
|
|
136
|
+
*
|
|
137
|
+
* `undefined` before `init()` is called.
|
|
138
|
+
*/
|
|
139
|
+
planStateProvider: PlanStateProvider | undefined;
|
|
140
|
+
/** Absolute path to the project root. Defaults to `Bun.env.PWD ?? "."`. */
|
|
141
|
+
private readonly projectRoot;
|
|
142
|
+
/**
|
|
143
|
+
* Injected OpenCode client facade.
|
|
144
|
+
*
|
|
145
|
+
* Provided by the caller at construction time. `undefined` when the adapter
|
|
146
|
+
* is constructed without a client (translation-only mode). No global SDK
|
|
147
|
+
* state is created or mutated by the adapter.
|
|
148
|
+
*/
|
|
149
|
+
private readonly openCodeClient;
|
|
150
|
+
/**
|
|
151
|
+
* OpenCode model context for model resolution.
|
|
152
|
+
*
|
|
153
|
+
* Provided by the caller at construction time. When `undefined`, model
|
|
154
|
+
* resolution falls back to the engine's constant fallback model.
|
|
155
|
+
*/
|
|
156
|
+
private readonly modelContext;
|
|
157
|
+
/**
|
|
158
|
+
* Harness-provided skill list.
|
|
159
|
+
*
|
|
160
|
+
* Injected at construction time by the caller (e.g. an OpenCode plugin entry
|
|
161
|
+
* point that received the skill list from the harness SDK). The adapter
|
|
162
|
+
* forwards this list to the engine via `loadAvailableSkills()` without
|
|
163
|
+
* performing any filesystem scanning.
|
|
164
|
+
*
|
|
165
|
+
* `undefined` when no skills were injected (adapter returns empty list).
|
|
166
|
+
*/
|
|
167
|
+
private readonly harnessSkills;
|
|
168
|
+
constructor(options?: OpenCodeAdapterOptions);
|
|
169
|
+
/**
|
|
170
|
+
* Perform one-time initialisation required before any agent can be
|
|
171
|
+
* materialised. Called exactly once by the bootstrap entry point.
|
|
172
|
+
*
|
|
173
|
+
* Constructs a `BunFilesystemPlanStateProvider` rooted at `this.projectRoot`
|
|
174
|
+
* and stores it as `this.planStateProvider` for use in lifecycle calls.
|
|
175
|
+
*/
|
|
176
|
+
init(): Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* Return the list of skills available in the current OpenCode instance.
|
|
179
|
+
*
|
|
180
|
+
* Forwards the harness-provided skill list injected at construction time via
|
|
181
|
+
* `OpenCodeAdapterOptions.availableSkills`. The OpenCode harness (SDK/runtime)
|
|
182
|
+
* is responsible for discovering which skills exist; the adapter's role is to
|
|
183
|
+
* receive that list and forward it to the engine for skill resolution.
|
|
184
|
+
*
|
|
185
|
+
* When no skills were injected, returns an empty list. The engine will then
|
|
186
|
+
* emit `MissingSkill` errors for any declared skills that cannot be resolved —
|
|
187
|
+
* this is the correct hard-error behavior (no silent skips).
|
|
188
|
+
*
|
|
189
|
+
* Boundary rule: this method must not scan the filesystem, query harness
|
|
190
|
+
* directories, or perform any harness-owned discovery. All discovery is
|
|
191
|
+
* delegated to the harness and injected via the constructor.
|
|
192
|
+
*/
|
|
193
|
+
loadAvailableSkills(): Promise<SkillInfo[]>;
|
|
194
|
+
/**
|
|
195
|
+
* Materialise a sub-agent from the provided normalized descriptor.
|
|
196
|
+
*
|
|
197
|
+
* ## Flow
|
|
198
|
+
*
|
|
199
|
+
* 1. Resolve the model for this agent using `resolveModelForAgent()` with
|
|
200
|
+
* the adapter-provided OpenCode model context. Returns `err` on model
|
|
201
|
+
* resolution failure (e.g. unsupported explicit subagent model).
|
|
202
|
+
* 2. Translate the descriptor into an OpenCode `AgentConfig` via
|
|
203
|
+
* `translateAgent`, passing the resolved model. Returns `err` on failure.
|
|
204
|
+
* 3. Store the translated config in `translatedAgents` for test inspection
|
|
205
|
+
* and transitional compatibility.
|
|
206
|
+
* 4. When an `OpenCodeClientFacade` is available, call `reconcileAgent()` to
|
|
207
|
+
* perform the SDK-backed `list → reconcile → create/update` flow.
|
|
208
|
+
* Returns `err` on reconciliation failure (including collision errors).
|
|
209
|
+
* 5. When no client is available, log a warning and return `ok(undefined)`
|
|
210
|
+
* (translation-only mode — no SDK calls are made).
|
|
211
|
+
*
|
|
212
|
+
* @param descriptor - Full normalized agent descriptor to materialise.
|
|
213
|
+
* @returns `ok(undefined)` on success, `err(OpenCodeAdapterError)` on failure.
|
|
214
|
+
*/
|
|
215
|
+
spawnSubagent(descriptor: AgentDescriptor): ResultAsync<void, OpenCodeAdapterError>;
|
|
216
|
+
}
|
|
217
|
+
export {};
|
|
218
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,SAAS,EACV,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAK1D,KAAK,wBAAwB,GACzB,sBAAsB,GACtB,qBAAqB,GACrB,qBAAqB,CAAC;AAE1B,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;gBAEZ,KAAK,EAAE;QACjB,IAAI,EAAE,wBAAwB,CAAC;QAC/B,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CAOF;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAEvC;;;;;;;;OAQG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAC;IAE7C;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,EAAE,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,eAAgB,YAAW,cAAc;IACpD;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAa;IAExE;;;;;;;OAOG;IACH,iBAAiB,EAAE,iBAAiB,GAAG,SAAS,CAAa;IAE7D,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAmC;IAElE;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuB;IAEpD;;;;;;;;;OASG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0B;gBAE5C,OAAO,GAAE,sBAA2B;IAOhD;;;;;;OAMG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAa3B;;;;;;;;;;;;;;;OAeG;IACG,mBAAmB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IASjD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,aAAa,CACX,UAAU,EAAE,eAAe,GAC1B,WAAW,CAAC,IAAI,EAAE,oBAAoB,CAAC;CAiG3C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command templates for OpenCode slash commands.
|
|
3
|
+
*
|
|
4
|
+
* These templates are injected into the conversation when the user types
|
|
5
|
+
* `/start-work` or `/weave:start` in the OpenCode TUI. They instruct the
|
|
6
|
+
* Tapestry agent to execute a Weave plan.
|
|
7
|
+
*
|
|
8
|
+
* ## How OpenCode commands work
|
|
9
|
+
*
|
|
10
|
+
* OpenCode commands are prompt-based — when a user types `/start-work my-plan`,
|
|
11
|
+
* OpenCode replaces `$ARGUMENTS` with `my-plan` and sends the template as a
|
|
12
|
+
* user message to the configured agent. This is NOT programmatic execution;
|
|
13
|
+
* it's prompt injection that instructs the agent to act.
|
|
14
|
+
*
|
|
15
|
+
* ## Placeholders
|
|
16
|
+
*
|
|
17
|
+
* - `$ARGUMENTS` — the text after the command name (e.g. plan name)
|
|
18
|
+
* - `$SESSION_ID` — OpenCode session identifier
|
|
19
|
+
* - `$TIMESTAMP` — ISO-8601 timestamp of command invocation
|
|
20
|
+
*
|
|
21
|
+
* @see https://opencode.ai/docs/commands/ — OpenCode commands documentation
|
|
22
|
+
* @see docs/adapter-bootstrap.md — Command Surface Registration section
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Template for the `/start-work` slash command (legacy name).
|
|
26
|
+
*
|
|
27
|
+
* Registered as `cfg.command["start-work"]` in the plugin config hook.
|
|
28
|
+
* When invoked, OpenCode sends this template to the Tapestry agent.
|
|
29
|
+
*/
|
|
30
|
+
export declare const START_WORK_COMMAND_TEMPLATE: string;
|
|
31
|
+
/**
|
|
32
|
+
* Template for the `/weave:start` slash command (preferred name).
|
|
33
|
+
*
|
|
34
|
+
* Registered as `cfg.command["weave:start"]` in the plugin config hook.
|
|
35
|
+
* When invoked, OpenCode sends this template to the Tapestry agent.
|
|
36
|
+
*/
|
|
37
|
+
export declare const WEAVE_START_COMMAND_TEMPLATE: string;
|
|
38
|
+
//# sourceMappingURL=command-templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-templates.d.ts","sourceRoot":"","sources":["../src/command-templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAkFH;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,QAKA,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,QAKD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @weaveio/weave-adapter-opencode
|
|
3
|
+
*
|
|
4
|
+
* OpenCode harness adapter and plugin entry point for the Weave orchestration
|
|
5
|
+
* framework.
|
|
6
|
+
*
|
|
7
|
+
* This package serves two roles:
|
|
8
|
+
*
|
|
9
|
+
* 1. **OpenCode plugin** — When listed in `opencode.json`'s `plugin` array,
|
|
10
|
+
* OpenCode loads this package at startup and calls the default-exported
|
|
11
|
+
* `WeavePlugin` function. The plugin materializes all agents declared in
|
|
12
|
+
* `.weave/config.weave` into the running OpenCode instance.
|
|
13
|
+
*
|
|
14
|
+
* 2. **Harness adapter library** — `OpenCodeAdapter` implements the
|
|
15
|
+
* `HarnessAdapter` interface and can be used programmatically by any caller
|
|
16
|
+
* that wants to materialize Weave agents into OpenCode.
|
|
17
|
+
*
|
|
18
|
+
* ## Installation as an OpenCode plugin
|
|
19
|
+
*
|
|
20
|
+
* Use the `./plugin` subpath export — **not** the bare package name:
|
|
21
|
+
*
|
|
22
|
+
* ```jsonc
|
|
23
|
+
* // opencode.json
|
|
24
|
+
* {
|
|
25
|
+
* "plugin": ["@weaveio/weave-adapter-opencode/plugin"]
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* The bare `@weaveio/weave-adapter-opencode` entry (`dist/index.js`, this file) exports
|
|
30
|
+
* non-function values (constants, type re-exports) that cause OpenCode's
|
|
31
|
+
* `getLegacyPlugins` loader to throw `TypeError: Plugin export is not a function`.
|
|
32
|
+
* Use `@weaveio/weave-adapter-opencode/plugin` (`dist/plugin.js`) as the OpenCode plugin
|
|
33
|
+
* entry point. This barrel is for programmatic use only.
|
|
34
|
+
*
|
|
35
|
+
* Restart OpenCode after adding the plugin. The plugin entry point receives
|
|
36
|
+
* the runtime context, constructs an `OpenCodeAdapter` with the injected SDK
|
|
37
|
+
* client, and materializes all agents declared in `.weave/config.weave`.
|
|
38
|
+
*
|
|
39
|
+
* ## Boundary rule
|
|
40
|
+
*
|
|
41
|
+
* This package is the only consumer of `@opencode-ai/sdk` and
|
|
42
|
+
* `@opencode-ai/plugin`. All SDK type imports flow through `./sdk-types` —
|
|
43
|
+
* never directly from the SDK package. Plugin types are confined to
|
|
44
|
+
* `./plugin.ts`.
|
|
45
|
+
*/
|
|
46
|
+
export type { OpenCodeAdapterOptions } from "./adapter.js";
|
|
47
|
+
export { OpenCodeAdapter, OpenCodeAdapterError } from "./adapter.js";
|
|
48
|
+
export type { ModelResolutionError, OpenCodeModelContext, } from "./model-resolution.js";
|
|
49
|
+
export { resolveModelForAgent } from "./model-resolution.js";
|
|
50
|
+
export type { OpenCodeClientError, OpenCodeClientFacade, } from "./opencode-client.js";
|
|
51
|
+
export { SdkOpenCodeClient } from "./opencode-client.js";
|
|
52
|
+
export type { ReconcileAgentError, ReconcileDecision, } from "./reconcile-agent.js";
|
|
53
|
+
export { classifyExistingAgent, reconcileAgent, tagWithOwnership, WEAVE_OWNERSHIP_TAG, } from "./reconcile-agent.js";
|
|
54
|
+
export type { RunWorkflowError, RunWorkflowInput, RunWorkflowResult, } from "./run-workflow.js";
|
|
55
|
+
export { runWorkflow } from "./run-workflow.js";
|
|
56
|
+
export type { StartPlanExecutionError, StartPlanExecutionInput, } from "./start-plan-execution.js";
|
|
57
|
+
export { DEFAULT_EXECUTION_WORKFLOW, startPlanExecution, WEAVE_START_COMMAND, WEAVE_START_LEGACY_COMMAND, } from "./start-plan-execution.js";
|
|
58
|
+
export type { AbortExecutionProjectionInput, AdvanceStepProjectionInput, InspectStatusProjectionInput, ProjectionDegraded, ProjectionFailure, ProjectionResult, ProjectionSuccess, RuntimeHealthProjectionInput, RunWorkflowProjectionInput, StartPlanProjectionInput, } from "./runtime-command-projection.js";
|
|
59
|
+
export { buildOpenCodeHealthReport, createDefaultStore, DEGRADED_AFFORDANCES, RuntimeCommandProjection, WEAVE_COMMAND_LABELS, } from "./runtime-command-projection.js";
|
|
60
|
+
export { START_WORK_COMMAND_TEMPLATE, WEAVE_START_COMMAND_TEMPLATE, } from "./command-templates.js";
|
|
61
|
+
export { buildSkillInfoList, validateDeclaredSkills, } from "./skill-discovery.js";
|
|
62
|
+
export type { Plugin, PluginInput, PluginModule } from "@opencode-ai/plugin";
|
|
63
|
+
export type { WeavePluginOptions } from "./plugin.js";
|
|
64
|
+
/**
|
|
65
|
+
* Default log file path relative to the project directory.
|
|
66
|
+
*
|
|
67
|
+
* When the OpenCode plugin runs without an explicit `WEAVE_LOG_FILE` env var,
|
|
68
|
+
* Weave logs are written to this path under the project root. The `.weave/`
|
|
69
|
+
* directory is already the conventional home for Weave project state, so
|
|
70
|
+
* placing the log file there keeps everything in one place.
|
|
71
|
+
*
|
|
72
|
+
* Example: `/path/to/project/.weave/weave.log`
|
|
73
|
+
*
|
|
74
|
+
* Defined here (not re-exported from `plugin.ts`) because the plugin entry
|
|
75
|
+
* point must export only functions to satisfy OpenCode's `getLegacyPlugins`
|
|
76
|
+
* loader. This constant is safe to export from the barrel.
|
|
77
|
+
*/
|
|
78
|
+
export declare const DEFAULT_PLUGIN_LOG_SUBPATH = ".weave/weave.log";
|
|
79
|
+
/**
|
|
80
|
+
* Default export: the OpenCode `Plugin` function.
|
|
81
|
+
*
|
|
82
|
+
* OpenCode loads this as the plugin entry point when `@weaveio/weave-adapter-opencode`
|
|
83
|
+
* is listed in `opencode.json`'s `plugin` array.
|
|
84
|
+
*/
|
|
85
|
+
export { createWeavePlugin, server as WeavePluginServer, WeavePlugin, WeavePlugin as default, } from "./plugin.js";
|
|
86
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAMH,YAAY,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMrE,YAAY,EACV,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAM7D,YAAY,EACV,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAMzD,YAAY,EACV,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAM9B,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhD,YAAY,EACV,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,2BAA2B,CAAC;AAMnC,YAAY,EACV,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,4BAA4B,EAC5B,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAM9B,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAE7D;;;;;GAKG;AACH,OAAO,EACL,iBAAiB,EACjB,MAAM,IAAI,iBAAiB,EAC3B,WAAW,EACX,WAAW,IAAI,OAAO,GACvB,MAAM,aAAa,CAAC"}
|