opencode-dev-framework 0.1.28 → 0.2.2

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 CHANGED
@@ -18,11 +18,10 @@ reimplemented as an OpenCode-native plugin.
18
18
  - **Per-edit lint.** Runs your configured linter on each file the agent edits
19
19
  and reports failures loudly. Optionally delegates per-file linting to
20
20
  `pre-commit run --files` when `precommit: auto` is set.
21
- - **Completion gate.** When the session goes idle, runs typecheck, tests, and
22
- (optionally) lint on changed files. In OpenCode versions with the
23
- `experimental.session.stopping` hook, gate failures keep the session running
24
- (up to `gate.max_blocks` times) so the agent must fix the failures. In older
25
- versions the gate reports loudly via `session.idle`.
21
+ - **Completion gate.** When the session goes idle (`session.idle`/`session.status:idle`),
22
+ runs typecheck, tests, and (optionally) lint on changed files. On failure inside
23
+ `gate.max_blocks` the plugin re-prompts the session with the failure summary,
24
+ keeping the agent loop alive (V2 async replacement for `session.stopping`).
26
25
  - **Custom tools.** `dev_framework_init` scaffolds project-level agents,
27
26
  skills, local rules directory, and config; `dev_framework_set_profile` changes the profile
28
27
  in-session without restarting; `dev_framework_status` reports the current
@@ -60,14 +59,13 @@ Then add the plugin to your project's `opencode.json`:
60
59
 
61
60
  ```json
62
61
  {
63
- "plugin": ["opencode-dev-framework"]
62
+ "plugins": ["opencode-dev-framework"]
64
63
  }
65
64
  ```
66
65
 
67
- On OpenCode 1.18.18+ the `./tui` companion (the `/df-status` and `/df-help`
68
- modals) is auto-discovered from the npm plugin entry above, so the server and
69
- TUI parts load together. (On older builds, or if the modals do not appear, also
70
- add the package to `tui.json` — see *Local development* below.)
66
+ Requires OpenCode `v2.0.0+` (`@opencode/plugin` `^2`). On `v1.18.18–1.18.31` use the `v1` branch
67
+ of this plugin (`plugin` key). The `./tui` companion (`/df-status` and `/df-help`
68
+ modals) is auto-discovered from the npm entry on `v2` — no separate `tui.json` needed.
71
69
 
72
70
  Finally, scaffold the project-level files (agents, skills, local rules directory,
73
71
  and default config) into your repo with the bundled `df` CLI:
@@ -94,25 +92,16 @@ local filesystem paths — it only loads when the package is listed in the TUI
94
92
  config. OpenCode reads `tui.json` from the global config dir
95
93
  (`~/.config/opencode/tui.json`) and the project dir (`.opencode/tui.json`).
96
94
 
97
- `opencode.json` (server plugin):
95
+ `opencode.json` (V2):
98
96
 
99
97
  ```json
100
98
  {
101
- "plugin": ["/home/jerome/opencode-dev-framework"]
102
- }
103
- ```
104
-
105
- `tui.json` (TUI plugin — same path):
106
-
107
- ```json
108
- {
109
- "plugin": ["/home/jerome/opencode-dev-framework"]
99
+ "plugins": ["/home/jerome/opencode-dev-framework"]
110
100
  }
111
101
  ```
112
102
 
113
103
  The path must be the **repository root** (where `package.json` lives). OpenCode
114
- loads the server plugin from `dist/index.js` and the TUI plugin from `tui.tsx`,
115
- so rebuild after every source change:
104
+ loads the plugin from `dist/index.js` (TUI from `tui.tsx`), so rebuild after every source change:
116
105
 
117
106
  ```bash
118
107
  npm run build
@@ -202,11 +191,12 @@ itself).
202
191
 
203
192
  ## Limitations
204
193
 
205
- - **The completion gate blocks only in newer OpenCode versions.** The
206
- `experimental.session.stopping` hook (PR #41811) lets the plugin keep the
207
- session running until checks pass. In older OpenCode versions the gate runs
208
- on `session.idle` and reports failures loudly but cannot force the agent to
209
- keep working.
194
+ - **The completion gate in V2 re-prompts instead of vetoing.** `session.stopping`
195
+ (`PR #44712`) was removed in the V2 plugin API. On failure inside `gate.max_blocks`
196
+ the plugin now calls `ctx.session.prompt()` from the `session.idle`/`session.status`
197
+ event, waking the agent with the failure summary — same UX, async instead of a
198
+ synchronous `stop=false` veto. Standing down after `max_blocks` is plugin-owned
199
+ (no core 3-re-entry cap). There is no synchronous hard block in V2.
210
200
  - **Guardrails run inside OpenCode.** The `tool.execute.before` hook runs
211
201
  after OpenCode's own permission system; it adds project rules on top, it
212
202
  does not replace OpenCode permissions.
package/dist/gate.d.ts CHANGED
@@ -3,8 +3,8 @@
3
3
  * session tries to stop, plus the changed-file tracking that feeds it.
4
4
  *
5
5
  * The gate runs from two call sites:
6
- * - `experimental.session.stopping` (OpenCode PR #41811): on failure, a
7
- * synthetic user message keeps the session running, up to `gate.max_blocks`.
6
+ * - `session.stopping` (OpenCode PR #44712): on failure, the adapter sets
7
+ * `stop: false` with a continuation message, up to `gate.max_blocks`.
8
8
  * - `session.idle` (fallback on older OpenCode): advisory logging only — by
9
9
  * then the agent's turn has already finished, so failures cannot block.
10
10
  */
package/dist/gate.js CHANGED
@@ -3,8 +3,8 @@
3
3
  * session tries to stop, plus the changed-file tracking that feeds it.
4
4
  *
5
5
  * The gate runs from two call sites:
6
- * - `experimental.session.stopping` (OpenCode PR #41811): on failure, a
7
- * synthetic user message keeps the session running, up to `gate.max_blocks`.
6
+ * - `session.stopping` (OpenCode PR #44712): on failure, the adapter sets
7
+ * `stop: false` with a continuation message, up to `gate.max_blocks`.
8
8
  * - `session.idle` (fallback on older OpenCode): advisory logging only — by
9
9
  * then the agent's turn has already finished, so failures cannot block.
10
10
  */
package/dist/index.d.ts CHANGED
@@ -1,37 +1,33 @@
1
1
  /**
2
- * opencode-dev-framework plugin entry point.
2
+ * opencode-dev-framework V2 plugin entry point.
3
3
  *
4
- * Wired so far:
5
- * - tool.execute.before -> protected-path / dangerous-command guardrails
6
- * - event (file.edited) -> per-edit lint + changed-file tracking
7
- * - event (session.idle) -> completion gate fallback (advisory logging)
8
- * - experimental.chat.system.transform -> constitution injection + session mapping
9
- * - experimental.session.stopping -> blocking completion gate (OpenCode >= PR #41811)
10
- * - config hook -> registers /df-profile and /df-verify prompt commands
11
- * - command.execute.before -> handles /df-profile, /df-verify, and unknown /df-*
4
+ * V2 framework (opencode v2): Plugin.define({ id, setup(ctx) })
5
+ * - ctx.session.hook("context", ...) -> constitution injection
6
+ * - ctx.tool.hook("execute.before", ...) -> guardrails
7
+ * - ctx.event.subscribe() -> file tracking + gate enforcement via re-prompt
8
+ * - ctx.tool.transform(...) -> custom tools
9
+ * - ctx.command.transform(...) -> slash commands (optional)
10
+ *
11
+ * Gate enforcement: no synchronous `session.stopping`. On `session.idle`
12
+ * / `session.status:idle` we run the gate and if it fails inside budget we
13
+ * call `ctx.session.prompt({ sessionID, text: stoppingMessage })` to wake the
14
+ * agent — async re-injection preserving the enforcement intent (see docs/plans/08-notes).
12
15
  */
13
- import type { Hooks, Plugin, PluginInput } from "@opencode-ai/plugin";
16
+ import { Plugin } from "@opencode/plugin";
14
17
  import { type ChangedFileTracker } from "./gate.js";
15
18
  import { type RunCommand } from "./host.js";
16
19
  import { type LogFn } from "./logger.js";
17
20
  import type { ResolvedConfig } from "./types.js";
18
- /**
19
- * The `experimental.session.stopping` hook was added in OpenCode PR #41811
20
- * and is not yet in the published `@opencode-ai/plugin` types. We define it
21
- * locally so the plugin compiles and automatically uses the hook when the
22
- * runtime supports it.
23
- */
24
- export interface HooksWithStopping extends Hooks {
25
- "experimental.session.stopping"?: (input: {
26
- sessionID: string;
27
- }, output: {
28
- context: string[];
29
- }) => Promise<void>;
21
+ export interface HookState {
22
+ directory: string;
23
+ config: ResolvedConfig;
24
+ log: LogFn;
25
+ run: RunCommand;
26
+ tracker: ChangedFileTracker;
27
+ constitution: string | null;
28
+ blockCounts: Map<string, number>;
29
+ precommitAvailable?: boolean;
30
+ configMtime?: number;
30
31
  }
31
- /**
32
- * Build the plugin's hooks and custom tools. Exported (rather than inlined in
33
- * the plugin) so tests can inject a stubbed command runner and tracker.
34
- */
35
- export declare function buildHooks(ctx: PluginInput, config: ResolvedConfig, log: LogFn, run?: RunCommand, tracker?: ChangedFileTracker, constitution?: string | null, configMtime?: number): HooksWithStopping;
36
- export declare const devFramework: Plugin;
37
- export default devFramework;
32
+ declare const plugin: Plugin.Plugin;
33
+ export default plugin;