opencode-dev-framework 1.7.0 → 1.8.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 +37 -33
- package/dist/harness.d.ts +20 -6
- package/dist/harness.js +49 -13
- package/dist/review.d.ts +16 -1
- package/dist/review.js +47 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ An [OpenCode](https://opencode.ai) plugin that enforces project-specific
|
|
|
11
11
|
quality gates during AI coding sessions — and verifies whole tasks, not just
|
|
12
12
|
edits, through `/df-goal`. Inspired by
|
|
13
13
|
[anticomputer/dev-framework](https://github.com/anticomputer/dev-framework),
|
|
14
|
-
reimplemented
|
|
14
|
+
reimplemented for OpenCode (the original supports Copilot, Claude, and Codex).
|
|
15
15
|
|
|
16
16
|
## Quickstart
|
|
17
17
|
|
|
@@ -21,36 +21,35 @@ Five minutes from zero to your first gated session:
|
|
|
21
21
|
opencode plugin add opencode-dev-framework
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
detected config, trial-runs it, and walks you through the rest, ending at a
|
|
26
|
-
config + `hardening.md` diff for your review:
|
|
24
|
+
In any project, run:
|
|
27
25
|
|
|
28
26
|
```text
|
|
29
27
|
/df-init
|
|
30
28
|
```
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
It scaffolds the templates, writes a detected config, trial-runs it, and
|
|
31
|
+
hands your session agent a brief — what was detected, what passed, Makefile
|
|
32
|
+
targets worth mapping to wrappers, at most 3 open questions. The agent
|
|
33
|
+
resolves what it can, asks only genuinely user-only questions, and ends with
|
|
34
|
+
a config + `hardening.md` draft for your review. Budget ~5 minutes,
|
|
35
|
+
review-only at the end; imperfections assumed, manual always possible.
|
|
36
|
+
|
|
37
|
+
Prefer a shell? Same thing non-interactively — for CI, dotfiles, and
|
|
38
|
+
scripted runs:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx df init
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Conflicts need `--overwrite-existing` or `--skip-existing` — everything
|
|
45
|
+
else is under `npx df init --help`.
|
|
46
|
+
|
|
47
|
+
Then ask the agent for a small edit. You will see the plugin working: the
|
|
48
|
+
edit is checked against guardrails before it lands, your linter runs on the
|
|
49
|
+
edited file, and when the session goes idle the completion gate runs your
|
|
47
50
|
typecheck/tests. `/df-status` shows the live state at any time. Start with
|
|
48
51
|
`profile: advisory` if you want to observe before enforcing.
|
|
49
52
|
|
|
50
|
-
Requires OpenCode `v2.x` — tested on `v2.0.26` and `v2.2.0`. On
|
|
51
|
-
`v1.18.18–1.18.31` use the `v1` branch (`plugin` key). Stuck? See
|
|
52
|
-
[`docs/user/troubleshooting.md`](docs/user/troubleshooting.md).
|
|
53
|
-
|
|
54
53
|
## What it does
|
|
55
54
|
|
|
56
55
|
- **Constitution injection.** Adds a project quality bar to the system prompt
|
|
@@ -155,22 +154,27 @@ How each layer is enforced, and what it honestly cannot do:
|
|
|
155
154
|
| `/df-help` | Instant modal: lists the dev-framework commands. |
|
|
156
155
|
| `/df-profile` | Instant modal picker (or `/df-profile <name>`): switches profile now, written to config. |
|
|
157
156
|
| `/df-verify` | Runs the verification suite manually; pass/fail summary in a modal. |
|
|
157
|
+
| `/df-init` | Server-side command: scaffolds templates, writes the detected config, trial-runs it, hands the brief to the agent. |
|
|
158
158
|
| `/df-goal <objective>` | Server-side command: starts a **verified** native goal (requires native `/goal`, a blocking profile, and at least one real check). |
|
|
159
159
|
|
|
160
|
-
The
|
|
161
|
-
|
|
160
|
+
The TUI commands open instantly and never feed the LLM; `/df-init` and
|
|
161
|
+
`/df-goal` are server-side and drive the session. Full reference:
|
|
162
162
|
[`docs/user/commands.md`](docs/user/commands.md).
|
|
163
163
|
|
|
164
164
|
## Limitations (short version)
|
|
165
165
|
|
|
166
|
-
The completion gate **steers, it does not veto**: it continues the turn
|
|
167
|
-
synthetic message at the idle boundary
|
|
168
|
-
when the failure repeats with no new edits)
|
|
169
|
-
can always close the session.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
166
|
+
- The completion gate **steers, it does not veto**: it continues the turn
|
|
167
|
+
via a synthetic message at the idle boundary — bounded by
|
|
168
|
+
`gate.max_blocks` (fewer when the failure repeats with no new edits) —
|
|
169
|
+
and you can always close the session.
|
|
170
|
+
- A genuine pre-stop veto is proposed upstream
|
|
171
|
+
([`anomalyco/opencode#54487`](https://github.com/anomalyco/opencode/pull/54487),
|
|
172
|
+
open) — if it lands, the gate vetoes there instead of continuing.
|
|
173
|
+
- The **pre-flight** gate is the one genuine hard block today.
|
|
174
|
+
- Guardrails add to OpenCode permissions, never replace them.
|
|
175
|
+
- Formatters and linters are yours — the plugin runs them, it does not
|
|
176
|
+
reimplement them.
|
|
177
|
+
|
|
174
178
|
Full story: [`docs/user/enforcement.md`](docs/user/enforcement.md).
|
|
175
179
|
|
|
176
180
|
## Troubleshooting
|
package/dist/harness.d.ts
CHANGED
|
@@ -43,12 +43,26 @@ export type ArtifactState = "missing" | "empty" | "present";
|
|
|
43
43
|
*/
|
|
44
44
|
export declare function artifactState(directory: string, relPath: string): Promise<ArtifactState>;
|
|
45
45
|
/**
|
|
46
|
-
* Grade the peer-review artifact including substance (plan 17 §3)
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
46
|
+
* Grade the peer-review artifact including substance (plan 17 §3) and
|
|
47
|
+
* freshness (plan 18): a substantive review of the wrong task reports
|
|
48
|
+
* `stale` unless it names every file this session changed. Never throws
|
|
49
|
+
* — unreadable files count as missing. Thin or template content names the
|
|
50
|
+
* duty-escape on the record instead of passing a checkbox note.
|
|
50
51
|
*/
|
|
51
|
-
export declare function readReviewState(directory: string): Promise<ReviewState>;
|
|
52
|
+
export declare function readReviewState(directory: string, changedFiles?: string[]): Promise<ReviewState>;
|
|
53
|
+
/**
|
|
54
|
+
* Files the freshness check covers: everything the session changed except
|
|
55
|
+
* the plugin's own bookkeeping, which the agent did not author — the
|
|
56
|
+
* review artifact itself (always tracked once written; self-reference
|
|
57
|
+
* would be absurd) and the runtime snapshot (plugin-written every
|
|
58
|
+
* continuation; surfaces via git where `.opencode/` is not ignored).
|
|
59
|
+
*/
|
|
60
|
+
export declare function coverableChangedFiles(directory: string, changedFiles: string[]): string[];
|
|
61
|
+
/**
|
|
62
|
+
* Uncovered files for the stale-review message. Empty when the artifact is
|
|
63
|
+
* unreadable — that path already reports `missing`, never `stale`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function uncoveredReviewFiles(directory: string, changedFiles: string[]): Promise<string[]>;
|
|
52
66
|
/**
|
|
53
67
|
* Parse `git status --porcelain=v1` output into repo-relative changed paths.
|
|
54
68
|
* Handles renames (`R old -> new` — keeps the new path) and dedupes.
|
|
@@ -168,7 +182,7 @@ export interface CompletionInspection {
|
|
|
168
182
|
changedFiles: string[];
|
|
169
183
|
report: GateReport;
|
|
170
184
|
reviewRequired: boolean;
|
|
171
|
-
/** Substance-graded review state (
|
|
185
|
+
/** Substance- and freshness-graded review state (plans 17 §3, 18): only `present` satisfies the duty. */
|
|
172
186
|
reviewState: ReviewState;
|
|
173
187
|
reviewMissing: boolean;
|
|
174
188
|
/** True when the gate short-circuited on `skip_unchanged` with no files. */
|
package/dist/harness.js
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
import { readFile, stat } from "node:fs/promises";
|
|
20
20
|
import { join } from "node:path";
|
|
21
21
|
import { runGate, summarizeGate } from "./gate.js";
|
|
22
|
-
import { assessReviewContent, templateReviewMessage, thinReviewMessage, } from "./review.js";
|
|
22
|
+
import { assessReviewContent, findUncoveredFiles, normalizeReviewPath, staleReviewMessage, templateReviewMessage, thinReviewMessage, } from "./review.js";
|
|
23
|
+
import { RUNTIME_STATUS_DIR, RUNTIME_STATUS_FILE } from "./runtime-status.js";
|
|
23
24
|
import { diffWeakening } from "./weakening.js";
|
|
24
25
|
/** Project-relative path of the peer-review artifact the agent must produce. */
|
|
25
26
|
export const REVIEW_ARTIFACT_REL = ".opencode/opencode-dev-framework/review.md";
|
|
@@ -47,12 +48,13 @@ export async function artifactState(directory, relPath) {
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
|
-
* Grade the peer-review artifact including substance (plan 17 §3)
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* Grade the peer-review artifact including substance (plan 17 §3) and
|
|
52
|
+
* freshness (plan 18): a substantive review of the wrong task reports
|
|
53
|
+
* `stale` unless it names every file this session changed. Never throws
|
|
54
|
+
* — unreadable files count as missing. Thin or template content names the
|
|
55
|
+
* duty-escape on the record instead of passing a checkbox note.
|
|
54
56
|
*/
|
|
55
|
-
export async function readReviewState(directory) {
|
|
57
|
+
export async function readReviewState(directory, changedFiles = []) {
|
|
56
58
|
let content;
|
|
57
59
|
try {
|
|
58
60
|
content = await readFile(join(directory, REVIEW_ARTIFACT_REL), "utf8");
|
|
@@ -60,7 +62,37 @@ export async function readReviewState(directory) {
|
|
|
60
62
|
catch {
|
|
61
63
|
return "missing";
|
|
62
64
|
}
|
|
63
|
-
|
|
65
|
+
const substance = assessReviewContent(content);
|
|
66
|
+
if (substance !== "present")
|
|
67
|
+
return substance;
|
|
68
|
+
return findUncoveredFiles(content, coverableChangedFiles(directory, changedFiles)).length > 0
|
|
69
|
+
? "stale"
|
|
70
|
+
: "present";
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Files the freshness check covers: everything the session changed except
|
|
74
|
+
* the plugin's own bookkeeping, which the agent did not author — the
|
|
75
|
+
* review artifact itself (always tracked once written; self-reference
|
|
76
|
+
* would be absurd) and the runtime snapshot (plugin-written every
|
|
77
|
+
* continuation; surfaces via git where `.opencode/` is not ignored).
|
|
78
|
+
*/
|
|
79
|
+
export function coverableChangedFiles(directory, changedFiles) {
|
|
80
|
+
const owned = new Set([REVIEW_ARTIFACT_REL, `${RUNTIME_STATUS_DIR}/${RUNTIME_STATUS_FILE}`]);
|
|
81
|
+
return changedFiles.map((f) => normalizeReviewPath(f, directory)).filter((f) => !owned.has(f));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Uncovered files for the stale-review message. Empty when the artifact is
|
|
85
|
+
* unreadable — that path already reports `missing`, never `stale`.
|
|
86
|
+
*/
|
|
87
|
+
export async function uncoveredReviewFiles(directory, changedFiles) {
|
|
88
|
+
let content;
|
|
89
|
+
try {
|
|
90
|
+
content = await readFile(join(directory, REVIEW_ARTIFACT_REL), "utf8");
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
return findUncoveredFiles(content, coverableChangedFiles(directory, changedFiles));
|
|
64
96
|
}
|
|
65
97
|
/**
|
|
66
98
|
* Parse `git status --porcelain=v1` output into repo-relative changed paths.
|
|
@@ -289,7 +321,9 @@ export async function inspectCompletion(deps) {
|
|
|
289
321
|
lintLimiter: deps.lintLimiter,
|
|
290
322
|
});
|
|
291
323
|
const gateFailed = report.ran && !report.ok;
|
|
292
|
-
const reviewState = reviewRequired
|
|
324
|
+
const reviewState = reviewRequired
|
|
325
|
+
? await readReviewState(directory, changedFiles)
|
|
326
|
+
: "present";
|
|
293
327
|
const reviewMissing = reviewRequired && reviewState !== "present";
|
|
294
328
|
const ok = !gateFailed && !reviewMissing && !weakened;
|
|
295
329
|
const baseSummary = gateFailed
|
|
@@ -298,11 +332,13 @@ export async function inspectCompletion(deps) {
|
|
|
298
332
|
? thinReviewMessage(changedFiles)
|
|
299
333
|
: reviewState === "template"
|
|
300
334
|
? templateReviewMessage(changedFiles)
|
|
301
|
-
:
|
|
302
|
-
?
|
|
303
|
-
:
|
|
304
|
-
?
|
|
305
|
-
:
|
|
335
|
+
: reviewState === "stale"
|
|
336
|
+
? staleReviewMessage(changedFiles, await uncoveredReviewFiles(directory, changedFiles))
|
|
337
|
+
: reviewMissing
|
|
338
|
+
? reviewMissingMessage(changedFiles)
|
|
339
|
+
: report.ran
|
|
340
|
+
? `completion gate passed\n${summarizeGate(report)}`
|
|
341
|
+
: `completion gate passed (${report.reason ?? "nothing to run"})`;
|
|
306
342
|
const summary = weakened ? `${weakeningSection(weakenings)}\n\n${baseSummary}` : baseSummary;
|
|
307
343
|
if (deps.passCache !== undefined) {
|
|
308
344
|
if (!gateFailed && !reviewMissing && !weakened && report.ran && fingerprint !== null) {
|
package/dist/review.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare const REVIEW_MIN_CHARS = 200;
|
|
|
3
3
|
/** Whitespace-separated-token floor for a substantive review. */
|
|
4
4
|
export declare const REVIEW_MIN_WORDS = 30;
|
|
5
5
|
/** Review artifact state with substance gradations. */
|
|
6
|
-
export type ReviewState = "missing" | "empty" | "thin" | "template" | "present";
|
|
6
|
+
export type ReviewState = "missing" | "empty" | "thin" | "template" | "stale" | "present";
|
|
7
7
|
/**
|
|
8
8
|
* Assess already-read review content. Pure. Order matters: empty,
|
|
9
9
|
* then template markers (a short file with TODOs reports the more
|
|
@@ -12,3 +12,18 @@ export type ReviewState = "missing" | "empty" | "thin" | "template" | "present";
|
|
|
12
12
|
export declare function assessReviewContent(content: string): Exclude<ReviewState, "missing">;
|
|
13
13
|
export declare function thinReviewMessage(changedFiles: string[]): string;
|
|
14
14
|
export declare function templateReviewMessage(changedFiles: string[]): string;
|
|
15
|
+
/**
|
|
16
|
+
* Normalize a changed-file entry to the repo-relative `/`-separated form
|
|
17
|
+
* reviews are matched against. Tracker and git entries already arrive
|
|
18
|
+
* repo-relative; absolute entries under the project still match by
|
|
19
|
+
* relativizing, and separators normalize so Windows-style paths match.
|
|
20
|
+
*/
|
|
21
|
+
export declare function normalizeReviewPath(file: string, directory: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Changed files the review text does not cover (plan 18). A file counts as
|
|
24
|
+
* covered when the review names it — relative or absolute (absolute paths
|
|
25
|
+
* contain the relative form). Boundary-guarded so `b-a.ts` does not cover
|
|
26
|
+
* `a.ts` and `a.tsx` does not cover `a.ts`. Pure.
|
|
27
|
+
*/
|
|
28
|
+
export declare function findUncoveredFiles(content: string, files: string[]): string[];
|
|
29
|
+
export declare function staleReviewMessage(changedFiles: string[], uncovered: string[]): string;
|
package/dist/review.js
CHANGED
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
* it only puts checkboxing on the record for honest-but-eager
|
|
15
15
|
* agents.
|
|
16
16
|
*
|
|
17
|
+
* Freshness (plan 18) sits beside substance: a substantive review of
|
|
18
|
+
* the *wrong task* fails as `stale` unless it names every file this
|
|
19
|
+
* session changed. Same out-of-scope line — deliberate misnaming
|
|
20
|
+
* (naming files without reviewing them) is sabotage, not eagerness.
|
|
21
|
+
*
|
|
17
22
|
* The artifact path literal mirrors `REVIEW_ARTIFACT_REL` in
|
|
18
23
|
* `harness.ts` (kept inline to avoid a module cycle; both are
|
|
19
24
|
* pinned by tests).
|
|
@@ -86,3 +91,45 @@ export function templateReviewMessage(changedFiles) {
|
|
|
86
91
|
`and resolutions, with every placeholder replaced by real findings.\n\n` +
|
|
87
92
|
reviewCadenceReminder());
|
|
88
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Escape a literal for embedding in a RegExp.
|
|
96
|
+
*/
|
|
97
|
+
function escapeRegExp(literal) {
|
|
98
|
+
return literal.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Normalize a changed-file entry to the repo-relative `/`-separated form
|
|
102
|
+
* reviews are matched against. Tracker and git entries already arrive
|
|
103
|
+
* repo-relative; absolute entries under the project still match by
|
|
104
|
+
* relativizing, and separators normalize so Windows-style paths match.
|
|
105
|
+
*/
|
|
106
|
+
export function normalizeReviewPath(file, directory) {
|
|
107
|
+
let rel = file;
|
|
108
|
+
if (rel.startsWith(directory) &&
|
|
109
|
+
(rel[directory.length] === "/" || rel[directory.length] === "\\")) {
|
|
110
|
+
rel = rel.slice(directory.length + 1);
|
|
111
|
+
}
|
|
112
|
+
return rel.replace(/\\/g, "/");
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Changed files the review text does not cover (plan 18). A file counts as
|
|
116
|
+
* covered when the review names it — relative or absolute (absolute paths
|
|
117
|
+
* contain the relative form). Boundary-guarded so `b-a.ts` does not cover
|
|
118
|
+
* `a.ts` and `a.tsx` does not cover `a.ts`. Pure.
|
|
119
|
+
*/
|
|
120
|
+
export function findUncoveredFiles(content, files) {
|
|
121
|
+
return files.filter((file) => {
|
|
122
|
+
const pattern = new RegExp(`(?<![\\w-])${escapeRegExp(file)}(?![\\w-])`);
|
|
123
|
+
return !pattern.test(content);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
export function staleReviewMessage(changedFiles, uncovered) {
|
|
127
|
+
const files = changedFiles.map((f) => ` - ${f}`).join("\n");
|
|
128
|
+
const missing = uncovered.map((f) => ` - ${f}`).join("\n");
|
|
129
|
+
return (`opencode-dev-framework completion gate — the peer-review artifact is substantive ` +
|
|
130
|
+
`but stale: it does not cover this session's changes. Not mentioned:\n${missing}\n\n` +
|
|
131
|
+
`This session changed files:\n${files}\n\n` +
|
|
132
|
+
`Rewrite ${REVIEW_REL} fresh for THIS session's changes — scope, findings, ` +
|
|
133
|
+
`and resolutions, naming every file above.\n\n` +
|
|
134
|
+
reviewCadenceReminder());
|
|
135
|
+
}
|