opencode-dev-framework 1.1.0 → 1.3.0

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
@@ -1,370 +1,179 @@
1
1
  # opencode-dev-framework
2
2
 
3
+ AI agents finish by *saying* they're done — and prose rules ("be
4
+ thorough", "run the tests") are interpretation surface a capable agent
5
+ routes around. This plugin replaces assertion with evidence: guardrails
6
+ that deny instead of advise, a completion gate that re-runs your checks
7
+ at the idle boundary, and verified goals whose contract requires a
8
+ tool-result PASS on the final tree. Exit codes don't negotiate.
9
+
3
10
  An [OpenCode](https://opencode.ai) plugin that enforces project-specific
4
11
  quality gates during AI coding sessions — and verifies whole tasks, not just
5
12
  edits, through `/df-goal`. Inspired by
6
13
  [anticomputer/dev-framework](https://github.com/anticomputer/dev-framework),
7
14
  reimplemented as an OpenCode-native plugin.
8
15
 
9
- ## What it does
10
-
11
- - **Constitution injection.** Adds a project constitution (quality bar, test
12
- discipline, focus rules) to the system prompt at session start. Ships with a
13
- bundled default split into numbered rule files. Override it by dropping files
14
- in `.opencode/opencode-dev-framework/rules/`, by setting explicit `rules`, or
15
- by letting the plugin auto-discover `STYLE.md` / `CONTRIBUTING.md`.
16
- - **Guardrails.** Blocks or warns on edits to protected paths (`.env` files,
17
- `node_modules`, vendored code, your own globs) and on dangerous shell
18
- commands (`git push`, `rm -rf`, `git reset --hard`, ...).
19
- - **Per-edit lint.** Runs your configured linter on each file the agent edits
20
- and reports failures loudly. Optionally delegates per-file linting to
21
- `pre-commit run --files` when `precommit: auto` is set.
22
- - **Completion gate.** At the would-go-idle boundary (`session.hook("experimental.idle")`,
23
- with an `idle` alias registered for a future rename), runs typecheck, tests,
24
- named acceptance commands (`gate.acceptance`), and (optionally) lint on changed files — changed files are
25
- tracked from edit events and cross-checked against `git status`, so the gate cannot
26
- silently skip due to an event-shape mismatch. In `standard`/`strict`, sessions that
27
- changed files must also produce a **peer-review artifact**
28
- (`.opencode/opencode-dev-framework/review.md`) covering the delegation rule's review
29
- cadence. On failure inside `gate.max_blocks` the plugin admits a synthetic
30
- continuation in the same execution with the failure summary. The
31
- `event.subscribe` idle net catches the boundaries the hook skips
32
- (interruption, failure, steer-parked drains) — deduped so one boundary never
33
- runs the gate twice, synthetic-first with `prompt` only as fallback.
34
- `/df-status` shows `Continuation (idle): active` once the hook has completed
35
- an evaluation, else the event-subscribe fallback.
36
- - **Verified goals (`/df-goal`).** Runs a whole task — typically a written
37
- plan — inside a native `/goal` with a verification contract appended:
38
- the agent must produce a `dev_framework_verify` PASS on the final tree,
39
- and the native reviewer weighs that tool result as completion evidence.
40
- Refuses vacuous configs, non-blocking profiles, and goal-less cores
41
- instead of starting an unverified substitute. See *Slash commands* below.
42
- - **Pre-flight gate (optional).** When a `preflight:` task list is configured, edit
43
- tools are **denied** (standard/strict) until the agent writes its pre-flight findings
44
- to `.opencode/opencode-dev-framework/preflight.md`. Use it for work that requires
45
- establishing baseline state/knowledge first (e.g. research on an existing strategy).
46
- Read-only tools stay open; the block lifts automatically once the artifact exists.
47
- - **Custom tools.** `dev_framework_init` scaffolds project-level agents,
48
- skills, local rules directory, and config; `dev_framework_set_profile` changes the profile
49
- in-session without restarting; `dev_framework_status` reports the current
50
- profile, guardrails, gate, and tracked changed files; `dev_framework_verify`
51
- runs the completion gate on demand and returns the summary to the agent.
52
- - **CLI installer.** `df init` auto-detects your language and writes a config
53
- with sensible commands; `df profile <name>` changes the profile from the
54
- shell; `df status` / `df version` report template state and the version.
55
- - **Slash commands.** The plugin registers four TUI commands that open instant
56
- modal dialogs and never feed anything to the LLM: `/df-status`, `/df-help`,
57
- `/df-profile` (bare for a picker, or with an argument), and `/df-verify`
58
- (runs the gate manually). `/df-goal <objective>` is a server-side command
59
- instead: it starts a verified native goal (see *Slash commands* below). The `dev_framework_*` custom *tools* above remain
60
- available for in-agent use.
61
-
62
- ### How it fits together
63
-
64
- ```mermaid
65
- flowchart TD
66
- G["/df-goal plan"] --> N["native /goal\nowns state + review"]
67
- N --> A["agent implements"]
68
- A --> B{"tool.execute.before"}
69
- B -- "deny: protected /\ndangerous / pre-flight" --> X["blocked before landing"]
70
- B -- allow --> C["edit lands"]
71
- C --> D["per-edit lint\n+ change tracker"]
72
- D --> V["agent runs\ndev_framework_verify"]
73
- V --> R{"verdict"}
74
- R -- PASS --> N
75
- R -- FAIL --> A
76
- D --> S{"session idle"}
77
- S --> GT["completion gate\nsame full contract"]
78
- GT -- PASS --> DONE["done"]
79
- GT -- "FAIL, within max_blocks" --> SYN["synthetic continuation"]
80
- SYN --> A
81
- GT -- "FAIL, past max_blocks" --> SD["stand down:\nhonest unmet report"]
82
- ```
83
-
84
- ## Profiles
85
-
86
- | Profile | Guardrails | Gate failures | Lint on edit | Pre-flight | Review required | Notes |
87
- | ---------- | ---------- | ------------- | ------------ | ---------- | --------------- | ----- |
88
- | `off` | disabled | not reported | no | no | no | Plugin registers no hooks at all. |
89
- | `advisory` | warn | warn | yes | warn only | warned, not blocked | Nothing blocks; everything is logged. |
90
- | `standard` | deny | error | yes | deny edits | blocks completion | The default when a config file exists. |
91
- | `strict` | deny | error | yes | deny edits | blocks completion | Also lints changed files in the gate; per-edit lint failures are reported loudly (error level — the edit already landed, so nothing throws there). |
92
-
93
- ## Enforcement layers
94
-
95
- How each mechanism is enforced on OpenCode `v2` (idle hook landed via
96
- [`anomalyco/opencode#59437`](https://github.com/anomalyco/opencode/pull/59437)):
97
-
98
- | Mechanism | Primary layer | Backstop / fallback | Strength |
99
- | --------- | ------------- | ------------------- | -------- |
100
- | Pre-flight gate | `tool.execute.before` deny | — | **Hard block** on every build: the edit never lands. |
101
- | Protected paths + dangerous commands | `tool.execute.before` deny/throw (load-bearing: the pipeline runs before-hooks first) | `permission.evaluate` native layer (deny) as defense-in-depth — it only ever sees calls the primary already passed; matters if core ever reorders the pipeline | **Hard block** via the primary deny; the native layer is belt-and-braces, never a weakening (it only denies or abstains). |
102
- | Per-edit lint | `tool.execute.after` track + lint | `filesystem.changed` event (this release) | Report-only: the edit already landed, so failures log loudly but never throw. |
103
- | Completion gate | `session.hook("experimental.idle")` (+ `idle` alias) → `session.synthetic` (same execution) | `event.subscribe` idle net for the boundaries the hook skips (deduped; synthetic-first, `prompt` fallback) | **Async, bounded** by `gate.max_blocks`. `/df-status` shows `Continuation (idle): active` vs the event-subscribe fallback. `execute.before` stays the only true hard wall. |
16
+ ## Quickstart
104
17
 
105
- ## Install
18
+ Five minutes from zero to your first gated session:
106
19
 
107
20
  ```bash
108
21
  npm install opencode-dev-framework
109
22
  ```
110
23
 
111
- Then add the plugin to your project's `opencode.jsonc`:
112
-
113
24
  ```json
25
+ // opencode.jsonc
114
26
  {
115
27
  "plugins": ["opencode-dev-framework"]
116
28
  }
117
29
  ```
118
30
 
119
- Requires OpenCode `v2.x` (`@opencode/plugin` `^2`) — tested on `v2.0.26`. On `v1.18.18–1.18.31` use the `v1` branch
120
- of this plugin (`plugin` key). The `./tui` companion (`/df-status` and `/df-help`
121
- modals) is auto-discovered from the npm entry on `v2` — no separate `tui.json` needed.
122
-
123
- Finally, scaffold the project-level files (agents, skills, local rules directory,
124
- and default config) into your repo with the bundled `df` CLI:
125
-
126
31
  ```bash
127
- npx df init # if installed locally as a project dependency
128
- # or, after npm i -g opencode-dev-framework:
129
- df init
32
+ npx df init
130
33
  ```
131
34
 
132
- `df init` is interactive by default: it asks before overwriting existing files.
133
- Use `--skip-existing` or `--overwrite-existing` for non-interactive runs.
134
- `df init` auto-detects your project's language and writes a matching
135
- `.opencode-dev-framework.yml` with sensible commands. `df status` shows what is
136
- and isn't scaffolded; `df profile off|advisory|standard|strict` changes the
137
- profile from the shell; `df version` prints the plugin version.
35
+ `df init` auto-detects your language and writes a matching
36
+ `.opencode-dev-framework.yml`. Then start a session in your project and ask
37
+ the agent for a small edit. You will see the plugin working: the edit is
38
+ checked against guardrails before it lands, your linter runs on the edited
39
+ file, and when the session goes idle the completion gate runs your
40
+ typecheck/tests. `/df-status` shows the live state at any time. Start with
41
+ `profile: advisory` if you want to observe before enforcing.
138
42
 
139
- ## Local development and testing
140
-
141
- To test the plugin from source without publishing to npm, point OpenCode at the
142
- local repository **root** in your project's `opencode.jsonc`:
143
-
144
- ```json
145
- {
146
- "plugins": [{ "package": "/home/jerome/opencode-dev-framework" }]
147
- }
148
- ```
43
+ Requires OpenCode `v2.x` — tested on `v2.0.26` and `v2.2.0`. On
44
+ `v1.18.18–1.18.31` use the `v1` branch (`plugin` key). Stuck? See
45
+ [`docs/user/troubleshooting.md`](docs/user/troubleshooting.md).
149
46
 
150
- The root path resolves through the package's `exports` map, so one entry
151
- loads **both** parts: the server (`dist/index.js` — hooks, guardrails, gate,
152
- custom tools) and the TUI (`tui.tsx` — `/df-status`, `/df-help` modals).
153
- Rebuild after every source change (`npm run build`) since OpenCode loads the
154
- compiled `dist/` output:
155
-
156
- ```bash
157
- npm run build
158
- ```
47
+ ## What it does
159
48
 
160
- ### Important caveats
161
-
162
- - Register the plugin **exactly once** per project. Plugin arrays **merge**
163
- across config files (global `opencode.jsonc`, project `./opencode.jsonc`,
164
- `./.opencode/opencode.json[c]`), so a second entry in another file —
165
- even one pointing at a different path of the same repo such as `dist/`
166
- — loads the same plugin ID twice and the duplicate fails with
167
- `Duplicate plugin ID: opencode-dev-framework` (check
168
- `opencode api get "/api/plugin?location[directory]=/path/to/project"`).
169
- If a session loads an unexpected plugin source, check all three locations.
170
- - Do **not** point the entry at `dist/` directly: a bare directory without
171
- `package.json`/`exports` resolves only the server part, so the TUI
172
- commands (`/df-status`, `/df-help`) never load. (On OpenCode `v2.0.x` the
173
- entrypoint resolved as `<dir>/index.js` and ignored `package.json`, which
174
- is why older revisions of this section recommended `dist/` — verified on
175
- `v2.2.0` that the root path resolves correctly through `exports`. The
176
- `.opencode/tui.json` listing from that era is likewise no longer needed:
177
- one `plugins` entry loads every part.)
178
- - OpenCode caches downloaded plugins in
179
- `~/.cache/opencode/packages/opencode-dev-framework*/`. If you previously
180
- loaded a published version and then switch to a local source, clear that
181
- cache so OpenCode does not reuse the old build:
182
-
183
- ```bash
184
- rm -rf ~/.cache/opencode/packages/opencode-dev-framework*
185
- ```
186
-
187
- ## Configuration
188
-
189
- Create `.opencode-dev-framework.yml` in your project root. The easiest way to
190
- override the bundled constitution is to run `df init` and then add Markdown
191
- files to `.opencode/opencode-dev-framework/rules/`.
49
+ - **Constitution injection.** Adds a project quality bar to the system prompt
50
+ at session start (bundled default, overridable per project).
51
+ - **Guardrails.** Blocks or warns on protected paths (`.env`, vendored
52
+ code, your own globs) and dangerous shell commands (`git push`, `rm -rf`).
53
+ - **Per-edit lint.** Runs your linter on each edited file and reports loudly.
54
+ - **Completion gate.** At the would-go-idle boundary, runs typecheck, tests,
55
+ acceptance checks, and (optionally) lint on changed files — plus a required
56
+ peer-review artifact in `standard`/`strict`. Failures steer the session
57
+ back with the failure summary, bounded by `gate.max_blocks` (fewer when
58
+ the failure repeats with no new edits — the gate stands down early on
59
+ zero progress).
60
+ - **Verified goals (`/df-goal`).** Wraps a task in native `/goal` with a
61
+ verification contract the reviewer weighs as evidence.
62
+ - **Pre-flight gate (optional).** Denies edits until the agent records
63
+ required upfront research.
64
+ - **Custom tools + CLI.** `dev_framework_*` tools for in-agent use;
65
+ `df init / profile / status / version` from the shell.
66
+
67
+ ## Minimal configuration
192
68
 
193
69
  ```yaml
194
70
  profile: standard
195
71
 
196
72
  commands:
197
- typecheck: "go build ./..."
198
- test: "go test ./..."
199
- lint:
200
- ".go": "golangci-lint run {dir}"
201
-
202
- protect:
203
- - ".env*"
204
- - "deploy/prod/**"
205
-
206
- gate:
207
- run_typecheck: true
208
- run_tests: true
209
- block_on_failure: true
210
- # standard/strict default: sessions that changed files must produce a
211
- # peer-review artifact (.opencode/opencode-dev-framework/review.md)
212
- # before the completion gate passes.
213
- require_review: true
214
-
215
- # Optional: named project-specific acceptance checks. Run sequentially
216
- # after the typecheck/test steps; a failure fails the gate but other
217
- # steps still run. Timeouts are per-check seconds (default: gate timeout).
218
- # acceptance:
219
- # - name: api-contract
220
- # command: "./scripts/verify-api-contract.sh"
221
- # - name: migration-safety
222
- # command: "./scripts/check-migrations.sh"
223
- # timeout: 120
224
-
225
- # Optional: pre-flight task list. When set, edit tools are denied
226
- # (standard/strict) until the agent writes its findings to
227
- # .opencode/opencode-dev-framework/preflight.md.
228
- # preflight:
229
- # - "Summarize the current strategy configuration and its intent"
230
- # - "Load the most recent backtest results and record headline metrics"
231
-
232
- on_edit:
233
- lint: true
234
-
235
- # Optional: delegate per-file linting to pre-commit when available
236
- # precommit: auto
237
-
238
- # Optional: explicit rule files (replace bundled; use mode: append to extend)
239
- # rules:
240
- # - docs/team-rules.md
241
- # Append form (keeps the bundled rules, adds project files after them):
242
- # rules:
243
- # mode: append
244
- # files:
245
- # - .opencode/opencode-dev-framework/hardening.md
246
-
247
- # Optional: project style guide appended to the constitution.
248
- # Auto-discovers STYLE.md / CONTRIBUTING.md / docs/STYLE.md when not set.
249
- # style_guide: STYLE.md
73
+ typecheck: "npm run typecheck"
74
+ test: "npm test"
250
75
  ```
251
76
 
252
- The legacy `.dev-framework.yml` flat-key format is read as a fallback for
253
- compatibility, but the native format above is preferred. See
254
- [`docs/plans/03-config-spec.md`](docs/plans/03-config-spec.md) for the full
255
- config reference and [`examples/go-service/`](examples/go-service/) for a
256
- complete example.
257
-
258
- ## Slash commands
259
-
260
- Five slash commands are **TUI commands** registered by the bundled `./tui`
261
- companion module (see *Local development* above for the `tui.json` requirement).
262
- They open instantly and **never** feed text back to the LLM:
263
-
264
- - `/df-status` — shows the current profile, guardrails, completion gate, and
265
- configured commands in a modal dialog.
266
- - `/df-runtime` — shows the plugin version and live hook/gate runtime state
267
- (which idle-hook method the core accepted, dispatch history) in a modal
268
- dialog. Read from a snapshot the server writes per project; reports
269
- "not reported yet" before the first session instead of guessing.
270
- - `/df-help` — lists the available dev-framework commands in a modal dialog.
271
- - `/df-profile` — opens a profile picker (off / advisory / standard / strict) in
272
- a modal dialog; selecting one switches the active profile immediately (written
273
- to the config file). With an argument (`/df-profile standard`) it switches
274
- directly with a toast instead of the picker.
275
- - `/df-verify` — runs the configured verification suite (the completion gate)
276
- manually and shows a pass/fail summary in a modal dialog.
277
-
278
- You can still run `df init` to install the bundled agents, skills, and default
279
- config; the commands themselves are provided by the plugin. The
280
- `dev_framework_*` custom *tools* remain
281
- available for in-agent use (e.g. when the model wants to change the profile
282
- itself).
283
-
284
- `/df-goal <objective>` is a **server-side command** instead (registered by the
285
- server plugin, not the TUI): it starts a **verified** native goal. The plugin
286
- appends a short verification contract to your objective verbatim and delegates
287
- exactly once to native `/goal`, which keeps owning state, review,
288
- pause/resume/clear, and continuations. Requires all three: native `/goal` on
289
- the core, a blocking profile (`standard`/`strict`, i.e.
290
- `gate.block_on_failure: true`), and at least one configured completion check
291
- (typecheck/test command, changed-file lint, `gate.acceptance`, or
292
- `gate.require_review`). Otherwise it fails with an actionable error instead of
293
- starting an unverified goal — use native `/goal` directly for purely semantic
294
- objectives. The objective plus addendum must fit native `/goal`'s 4,000-character
295
- limit; overflow is rejected, never truncated.
296
-
297
- The agent must run `dev_framework_verify` after its final changes; the native
298
- reviewer weighs that tool result as evidence and the framework idle gate stays
299
- an independent backstop. This is layered verification, not a hard lock:
300
- native `/goal` can still mark complete while the gate fails (or keep going
301
- after it passes), both tenants can admit a continuation at one idle boundary,
302
- and the framework stands down after `gate.max_blocks`.
303
-
304
- **Run plans under `/df-goal`.** When a task starts from a written plan, make
305
- the objective the plan inline (short plans) or `Implement the plan in <path>`
306
- (long plans). Native completion then requires the gate's PASS on the final
307
- tree — a stronger enforcement than a bare turn, where only your summary stands
308
- between the plan and "done".
309
-
310
- ## Limitations
311
-
312
- - **Post-flight enforcement is a same-execution continuation, not a veto.**
313
- At the would-go-idle boundary the `experimental.idle` hook (landed via
314
- [`anomalyco/opencode#59437`](https://github.com/anomalyco/opencode/pull/59437))
315
- runs the gate, and on failure inside `gate.max_blocks` admits a synthetic
316
- continuation in the same execution. The `event.subscribe` idle net covers
317
- the boundaries the hook skips (interruption, failure, steer-parked drains),
318
- deduped so one boundary never runs the gate twice. On builds without the
319
- hook only the net applies. `/df-status` shows which lever completed an
320
- evaluation (`Continuation (idle): active` vs the event-subscribe fallback).
321
- The user can always close the session, so treat the gate
322
- as the strongest available enforcement, not an unbreakable lock. The missing piece — a pre-terminal vote hook — is proposed upstream ([`anomalyco/opencode#54487`](https://github.com/anomalyco/opencode/pull/54487), open); until it lands, the above is the enforcement story. The **pre-flight**
323
- gate, by contrast, is a genuine hard block on every build: it denies edit tools in
324
- `tool.execute.before`, before the edit lands.
325
- - **Guardrails run inside OpenCode.** The `tool.execute.before` hook runs
326
- after OpenCode's own permission system; it adds project rules on top, it
327
- does not replace OpenCode permissions.
328
- - **Formatting and linting are delegated.** The plugin does not reimplement
329
- formatters or linters; you declare your linter commands in
330
- `.opencode-dev-framework.yml` and the plugin runs them on edited files and
331
- at the completion gate. Formatting is OpenCode core's job (`formatter` in
332
- `opencode.json`, off by default) — the plugin's `commands.format` /
333
- `on_edit.format` are accepted but ignored, deliberately not duplicated.
334
- The plugin does not automatically rewrite `opencode.json`
335
- formatter/permission fragments.
336
-
337
- ## Development
338
-
339
- ```bash
340
- npm install
341
- npm run format:check
342
- npm run lint
343
- npm run lint:md
344
- npm run typecheck
345
- npm run test
346
- npm run build
77
+ Full reference (all keys, acceptance checks, pre-flight, rule overrides):
78
+ [`docs/user/configuration.md`](docs/user/configuration.md). Copy-paste
79
+ starters: [`examples/go-service/`](examples/go-service/).
80
+
81
+ ## How it fits together
82
+
83
+ Every session runs the same loop — constitution, guardrails, lint, gate —
84
+ whether or not it starts under `/df-goal`. A goal just wraps that loop in
85
+ native verification:
86
+
87
+ ```text
88
+ user prompt
89
+ (plain or /df-goal plan)
90
+ |
91
+ v
92
+ agent implements
93
+ |
94
+ v
95
+ tool.execute.before
96
+ / \
97
+ allow deny: protected / dangerous / pre-flight
98
+ | |
99
+ v v
100
+ edit lands BLOCKED before landing
101
+ |
102
+ v
103
+ per-edit lint + change tracker
104
+ / \
105
+ v v
106
+ agent runs dev_framework_verify session idle
107
+ | |
108
+ v v
109
+ verdict completion gate (same full contract)
110
+ / \ | | | |
111
+ PASS FAIL PASS within max_blocks past max_blocks identical x3, no new edits
112
+ | | | | | |
113
+ v v v v v v
114
+ gate green loops back done synthetic STAND DOWN (honest unmet report)
115
+ (in a goal: to agent continuation
116
+ evidence implements |
117
+ into /goal) v
118
+ loops back to agent implements
119
+
120
+ wrappers (dotted lines in the diagram version):
121
+ /df-goal plan (optional) ── delegates once, appends contract ──> native /goal (owns objective + review)
122
+ native /goal ── wraps the loop, drives turns ──> agent implements
347
123
  ```
348
124
 
349
- For persistent debug traces, set `OPENCODE_DEV_FRAMEWORK_LOG_FILE`:
125
+ The diagram version of this flow (rendered on GitHub) lives in
126
+ [`docs/user/enforcement.md`](docs/user/enforcement.md#flow) — update both
127
+ together.
350
128
 
351
- ```bash
352
- OPENCODE_DEV_FRAMEWORK_LOG_FILE=/tmp/odf.log opencode run
353
- ```
129
+ ## Profiles
354
130
 
355
- Plugin code runs in the `opencode serve` backend, not in your terminal
356
- process — a variable exported only in the TUI shell never reaches it. For
357
- full server logs plus the plugin trace, run a private server:
131
+ | Profile | Guardrails | Gate failures | Lint on edit | Pre-flight | Review required | Notes |
132
+ | ---------- | ---------- | ------------- | ------------ | ---------- | --------------- | ----- |
133
+ | `off` | disabled | not reported | no | no | no | Plugin registers no hooks at all. |
134
+ | `advisory` | warn | warn | yes | warn only | warned, not blocked | Nothing blocks; everything is logged. |
135
+ | `standard` | deny | error | yes | deny edits | blocks completion | The default when a config file exists. |
136
+ | `strict` | deny | error | yes | deny edits | blocks completion | Also lints changed files in the gate. |
358
137
 
359
- ```bash
360
- OPENCODE_DEV_FRAMEWORK_LOG_FILE=/tmp/odf.log opencode run --standalone --print-logs
361
- ```
138
+ How each layer is enforced, and what it honestly cannot do:
139
+ [`docs/user/enforcement.md`](docs/user/enforcement.md).
140
+
141
+ ## Commands
142
+
143
+ | Command | What it does |
144
+ | ------- | -------------- |
145
+ | `/df-status` | Instant modal: profile, guardrails, gate, configured commands. |
146
+ | `/df-runtime` | Instant modal: plugin version + live hook/gate runtime state. |
147
+ | `/df-help` | Instant modal: lists the dev-framework commands. |
148
+ | `/df-profile` | Instant modal picker (or `/df-profile <name>`): switches profile now, written to config. |
149
+ | `/df-verify` | Runs the verification suite manually; pass/fail summary in a modal. |
150
+ | `/df-goal <objective>` | Server-side command: starts a **verified** native goal (requires native `/goal`, a blocking profile, and at least one real check). |
151
+
152
+ The first five are TUI commands — they open instantly and never feed the
153
+ LLM. Full reference:
154
+ [`docs/user/commands.md`](docs/user/commands.md).
155
+
156
+ ## Limitations (short version)
157
+
158
+ The completion gate **steers, it does not veto**: it continues the turn via a
159
+ synthetic message at the idle boundary (bounded by `gate.max_blocks` — fewer
160
+ when the failure repeats with no new edits), and you
161
+ can always close the session. A genuine pre-stop veto is proposed upstream
162
+ ([`anomalyco/opencode#54487`](https://github.com/anomalyco/opencode/pull/54487),
163
+ open) — if it lands, the gate vetoes there instead of continuing. The
164
+ **pre-flight** gate is the one genuine hard block today. Guardrails add to OpenCode permissions, never replace them. Formatters
165
+ and linters are yours — the plugin runs them, it does not reimplement them.
166
+ Full story: [`docs/user/enforcement.md`](docs/user/enforcement.md).
167
+
168
+ ## Troubleshooting
169
+
170
+ Duplicate plugin IDs, stale npm cache, TUI not loading, version matrix:
171
+ [`docs/user/troubleshooting.md`](docs/user/troubleshooting.md).
362
172
 
363
- (There is no `cli.json` interaction: the plugin never reads or writes CLI
364
- config; the flags above are stock OpenCode CLI options.)
173
+ ## Contributing
365
174
 
366
- See `AGENTS.md` and `docs/plans/` for the architecture and implementation
367
- plan.
175
+ `AGENTS.md` is the canonical contributor contract. Build/test commands and
176
+ the release path: [`docs/dev/contributing.md`](docs/dev/contributing.md).
368
177
 
369
178
  ## Disclaimer
370
179
 
package/bin/df CHANGED
@@ -6,12 +6,18 @@ import { readFile } from "node:fs/promises";
6
6
  import { dirname, join } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import {
9
+ buildWizardBrief,
10
+ formatTrialRun,
11
+ formatWizardBrief,
9
12
  installTemplates,
10
13
  resolveTargetDir,
11
14
  setProfileInFile,
12
15
  statusTemplates,
16
+ trialRunDetectedCommands,
13
17
  writeDetectedConfig,
14
18
  } from "../dist/installer.js";
19
+ import { detectProject } from "../dist/detect.js";
20
+ import { runCommand } from "../dist/host.js";
15
21
 
16
22
  async function getVersion() {
17
23
  const packagePath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
@@ -29,7 +35,12 @@ Usage:
29
35
  df version Print the plugin version
30
36
  df help Show this help
31
37
 
38
+ df init --wizard [dir] Scaffold, trial-run, and print an agent-handoff
39
+ brief (detection, trial results, Makefile targets,
40
+ open questions) for the project-config skill.
41
+
32
42
  Options:
43
+ --wizard Print the wizard brief after init (agent-led handoff)
33
44
  --overwrite-existing Overwrite files that already exist (non-interactive)
34
45
  --skip-existing Skip files that already exist (non-interactive)
35
46
  `);
@@ -122,6 +133,28 @@ async function main() {
122
133
  console.log(line);
123
134
  }
124
135
  console.log(`\nConfig: ${configResult.action}`);
136
+ if (flags.has("--wizard")) {
137
+ try {
138
+ const brief = await buildWizardBrief(targetDir, runCommand);
139
+ for (const line of ["", ...formatWizardBrief(brief)]) {
140
+ console.log(line);
141
+ }
142
+ } catch (error) {
143
+ console.log(`\n${formatBriefSkipped(error)}`);
144
+ }
145
+ } else if (configResult.action === "created" || configResult.action === "overwritten") {
146
+ try {
147
+ const { commands } = detectProject(targetDir);
148
+ const trial = await trialRunDetectedCommands(targetDir, commands, runCommand);
149
+ for (const line of ["", ...formatTrialRun(trial)]) {
150
+ console.log(line);
151
+ }
152
+ } catch (error) {
153
+ console.log(
154
+ `\nTrial-run: skipped (${error instanceof Error ? error.message : String(error)}) — verify commands manually`,
155
+ );
156
+ }
157
+ }
125
158
  }
126
159
 
127
160
  main().catch((error) => {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Persistent per-session completion-gate block counts.
2
+ * Persistent per-session completion-gate block counts (+ stuck snapshots).
3
3
  *
4
4
  * Counts live in `ctx.storage` (survives plugin reload / `session_move` /
5
5
  * server restart) with a caller-provided `Map` as the write-through L1
@@ -9,12 +9,14 @@
9
9
  * a broken storage backend degrades to pre-Phase-23 behavior instead of
10
10
  * breaking the gate.
11
11
  *
12
- * Stored values are only block counts (`number`). Never store secrets,
13
- * prompts, or file contents here.
12
+ * Stored values are only block counts (`number`) and stuck-detection
13
+ * snapshots (`{ signature, files, repeats }` — step names and relative
14
+ * paths, no file contents). Never store secrets, prompts, or file contents
15
+ * here.
14
16
  *
15
- * Key namespacing: counts are keyed `df:blocks:<sessionID>` (OpenCode
16
- * session IDs are globally unique, so this is safe even if storage is
17
- * shared across projects).
17
+ * Key namespacing: counts are keyed `df:blocks:<sessionID>`, snapshots
18
+ * `df:stuck:<sessionID>` (OpenCode session IDs are globally unique, so
19
+ * this is safe even if storage is shared across projects).
18
20
  *
19
21
  * Historical note: pre-cutover builds persisted a `df:stopSupported` flag
20
22
  * recording which stopping probe fired. The idle-first cutover removed
@@ -24,6 +26,7 @@ import type { Context } from "@opencode/plugin/promise/plugin";
24
26
  /** Minimal storage surface we need (subset of `Context["storage"]`). */
25
27
  export type StorageLike = Pick<Context["storage"], "get" | "set" | "remove">;
26
28
  export declare const BLOCK_COUNT_KEY_PREFIX = "df:blocks:";
29
+ export declare const STUCK_SNAPSHOT_KEY_PREFIX = "df:stuck:";
27
30
  export interface BlockStore {
28
31
  get(sessionID: string): Promise<number>;
29
32
  /** Read, add one, persist, and return the new count. */
@@ -35,3 +38,22 @@ export interface BlockStore {
35
38
  isDegraded(): boolean;
36
39
  }
37
40
  export declare function createBlockStore(storage: StorageLike | undefined | null, memory?: Map<string, number>): BlockStore;
41
+ /**
42
+ * Last blocked evaluation per session, for no-progress early stand-down
43
+ * (docs/plans/14-stuck-detection.md). `signature` identifies the failure (`gate:<sorted step
44
+ * names>` or `review`); `files` is the sorted changed-file list at that
45
+ * evaluation; `repeats` counts consecutive no-progress repeats so far.
46
+ */
47
+ export interface StuckSnapshot {
48
+ signature: string;
49
+ files: string[];
50
+ repeats: number;
51
+ }
52
+ export interface StuckSnapshotStore {
53
+ get(sessionID: string): Promise<StuckSnapshot | undefined>;
54
+ record(sessionID: string, snapshot: StuckSnapshot): Promise<void>;
55
+ clear(sessionID: string): Promise<void>;
56
+ readonly size: number;
57
+ isDegraded(): boolean;
58
+ }
59
+ export declare function createStuckSnapshotStore(storage: StorageLike | undefined | null, memory?: Map<string, StuckSnapshot>): StuckSnapshotStore;