opencode-dev-framework 1.7.0 → 1.9.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
@@ -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 as an OpenCode-native plugin.
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
- Then in any project, run `/df-init` — it scaffolds the templates, writes a
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
- Two ways in, same gate out — pick by how much attention you want to spend:
33
-
34
- - **Conversational (default).** `/df-init` hands your session agent a brief:
35
- what was detected, what passed, Makefile targets worth mapping to
36
- wrappers, at most 3 open questions. The agent resolves what it can, asks
37
- only genuinely user-only questions, and ends with a config + hardening
38
- draft for your review. Budget ~5 minutes, review-only at the end;
39
- imperfections assumed, manual always possible.
40
- - **Scripted.** `npx df init` from a shell: same scaffold, detect, and
41
- trial-run, no conversation. For CI, dotfiles, and non-interactive runs;
42
- conflicts need `--overwrite-existing` or `--skip-existing`.
43
-
44
- Then ask the agent for a small edit. You will see the plugin working: the edit is
45
- checked against guardrails before it lands, your linter runs on the edited
46
- file, and when the session goes idle the completion gate runs your
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,28 @@ 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
+ | `/df-update` | Server-side command: diffs installed templates against shipped, refresh/add each with user approval (detection only, never writes). |
158
159
  | `/df-goal <objective>` | Server-side command: starts a **verified** native goal (requires native `/goal`, a blocking profile, and at least one real check). |
159
160
 
160
- The first five are TUI commands — they open instantly and never feed the
161
- LLM. Full reference:
161
+ The TUI commands open instantly and never feed the LLM; `/df-init`,
162
+ `/df-update`, and `/df-goal` are server-side and drive the session. Full reference:
162
163
  [`docs/user/commands.md`](docs/user/commands.md).
163
164
 
164
165
  ## Limitations (short version)
165
166
 
166
- The completion gate **steers, it does not veto**: it continues the turn via a
167
- synthetic message at the idle boundary (bounded by `gate.max_blocks` — fewer
168
- when the failure repeats with no new edits), and you
169
- can always close the session. A genuine pre-stop veto is proposed upstream
170
- ([`anomalyco/opencode#54487`](https://github.com/anomalyco/opencode/pull/54487),
171
- open) — if it lands, the gate vetoes there instead of continuing. The
172
- **pre-flight** gate is the one genuine hard block today. Guardrails add to OpenCode permissions, never replace them. Formatters
173
- and linters are yours — the plugin runs them, it does not reimplement them.
167
+ - The completion gate **steers, it does not veto**: it continues the turn
168
+ via a synthetic message at the idle boundary — bounded by
169
+ `gate.max_blocks` (fewer when the failure repeats with no new edits) —
170
+ and you can always close the session.
171
+ - A genuine pre-stop veto is proposed upstream
172
+ ([`anomalyco/opencode#54487`](https://github.com/anomalyco/opencode/pull/54487),
173
+ open) — if it lands, the gate vetoes there instead of continuing.
174
+ - The **pre-flight** gate is the one genuine hard block today.
175
+ - Guardrails add to OpenCode permissions, never replace them.
176
+ - Formatters and linters are yours — the plugin runs them, it does not
177
+ reimplement them.
178
+
174
179
  Full story: [`docs/user/enforcement.md`](docs/user/enforcement.md).
175
180
 
176
181
  ## Troubleshooting
@@ -112,6 +112,7 @@ export function renderHelp() {
112
112
  lines.push("/df-verify Run the completion gate manually");
113
113
  lines.push("/df-goal Start a verified native goal (verification contract + native /goal)");
114
114
  lines.push("/df-init Set up this project (scaffold, detected config, trial-run, brief)");
115
+ lines.push("/df-update Check installed templates against shipped (refresh/add, approved per file)");
115
116
  lines.push("/df-help Show this message");
116
117
  lines.push("/df-runtime Show plugin version and live hook/gate runtime state");
117
118
  return lines.join("\n");
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
- * Never throws — unreadable files count as missing. Thin or
48
- * template content names the duty-escape on the record instead of
49
- * passing a checkbox note.
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 (plan 17 §3): only `present` satisfies the duty. */
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
- * Never throws — unreadable files count as missing. Thin or
52
- * template content names the duty-escape on the record instead of
53
- * passing a checkbox note.
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
- return assessReviewContent(content);
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.
@@ -146,6 +178,8 @@ function reviewMissingMessage(changedFiles) {
146
178
  `fail without the change, commands that actually pass), and code-reviewer / pattern-guardian ` +
147
179
  `for correctness and drift. Resolve every blocking finding, then write a summary of the ` +
148
180
  `review findings and their resolution to ${REVIEW_ARTIFACT_REL}.\n\n` +
181
+ `Do not re-run a specialist whose scope has not changed since its last report — ` +
182
+ `reuse that report and only re-run what your fixes invalidate.\n\n` +
149
183
  `Investigation-only reviewers: do not ask them to edit product code.`);
150
184
  }
151
185
  /** Create an empty pass cache (one per session state). */
@@ -289,7 +323,9 @@ export async function inspectCompletion(deps) {
289
323
  lintLimiter: deps.lintLimiter,
290
324
  });
291
325
  const gateFailed = report.ran && !report.ok;
292
- const reviewState = reviewRequired ? await readReviewState(directory) : "present";
326
+ const reviewState = reviewRequired
327
+ ? await readReviewState(directory, changedFiles)
328
+ : "present";
293
329
  const reviewMissing = reviewRequired && reviewState !== "present";
294
330
  const ok = !gateFailed && !reviewMissing && !weakened;
295
331
  const baseSummary = gateFailed
@@ -298,11 +334,13 @@ export async function inspectCompletion(deps) {
298
334
  ? thinReviewMessage(changedFiles)
299
335
  : reviewState === "template"
300
336
  ? templateReviewMessage(changedFiles)
301
- : reviewMissing
302
- ? reviewMissingMessage(changedFiles)
303
- : report.ran
304
- ? `completion gate passed\n${summarizeGate(report)}`
305
- : `completion gate passed (${report.reason ?? "nothing to run"})`;
337
+ : reviewState === "stale"
338
+ ? staleReviewMessage(changedFiles, await uncoveredReviewFiles(directory, changedFiles))
339
+ : reviewMissing
340
+ ? reviewMissingMessage(changedFiles)
341
+ : report.ran
342
+ ? `completion gate passed\n${summarizeGate(report)}`
343
+ : `completion gate passed (${report.reason ?? "nothing to run"})`;
306
344
  const summary = weakened ? `${weakeningSection(weakenings)}\n\n${baseSummary}` : baseSummary;
307
345
  if (deps.passCache !== undefined) {
308
346
  if (!gateFailed && !reviewMissing && !weakened && report.ran && fingerprint !== null) {
package/dist/index.d.ts CHANGED
@@ -15,6 +15,8 @@
15
15
  * - ctx.command.transform(...) -> server-side `/df-init` project setup
16
16
  * (deterministic scaffold in code, handoff back via session.prompt;
17
17
  * see src/init.ts)
18
+ * - ctx.command.transform(...) -> server-side `/df-update` template drift
19
+ * check (detection only, handoff back via session.prompt; see src/update.ts)
18
20
  *
19
21
  * Gate enforcement: no synchronous pre-stop veto. On `experimental.idle`
20
22
  * (same execution) we run the gate and if it fails inside budget we admit
package/dist/index.js CHANGED
@@ -15,6 +15,8 @@
15
15
  * - ctx.command.transform(...) -> server-side `/df-init` project setup
16
16
  * (deterministic scaffold in code, handoff back via session.prompt;
17
17
  * see src/init.ts)
18
+ * - ctx.command.transform(...) -> server-side `/df-update` template drift
19
+ * check (detection only, handoff back via session.prompt; see src/update.ts)
18
20
  *
19
21
  * Gate enforcement: no synchronous pre-stop veto. On `experimental.idle`
20
22
  * (same execution) we run the gate and if it fails inside budget we admit
@@ -897,6 +899,49 @@ const plugin = Plugin.define({
897
899
  error: String(err),
898
900
  });
899
901
  }
902
+ // 3d) Template refresh — server-side `/df-update` through
903
+ // `ctx.command.transform` (same shape as `/df-init`). Detects drift
904
+ // between the deployed templates and the shipped set, then hands the
905
+ // lists back through `session.prompt` with the invocation delivery, so
906
+ // the agent diffs, presents per file, and applies only what the user
907
+ // approves. Detection only — the command never writes.
908
+ try {
909
+ trackRegistration(await ctx.command.transform((editor) => {
910
+ editor.add({
911
+ name: "df-update",
912
+ description: "Check the project's installed templates against the shipped set and hand the drift to the agent: refresh differing files, add missing ones, each with user approval. Detection only, never writes.",
913
+ execute: async (invocation) => {
914
+ if (activeState !== state) {
915
+ throw new Error("Cannot check for updates: the plugin session state changed " +
916
+ "(teardown or reload raced the command); retry /df-update.");
917
+ }
918
+ const { runUpdateCommand } = await import("./update.js");
919
+ await runUpdateCommand({
920
+ directory: state.directory,
921
+ delivery: invocation.delivery,
922
+ checkAlive: () => {
923
+ if (activeState !== state) {
924
+ throw new Error("Update check was superseded mid-run (teardown or reload raced the command); " +
925
+ "retry /df-update — it only reads, never writes.");
926
+ }
927
+ },
928
+ deliver: async (text, delivery) => {
929
+ await ctx.session.prompt({
930
+ sessionID: invocation.sessionID,
931
+ text,
932
+ delivery,
933
+ });
934
+ },
935
+ });
936
+ },
937
+ });
938
+ }));
939
+ }
940
+ catch (err) {
941
+ await safeLog(state, "warn", "could not register df-update command; template updates unavailable", {
942
+ error: String(err),
943
+ });
944
+ }
900
945
  // 4) Event subscription — file tracking + gate enforcement net.
901
946
  // Runs the gate on `session.idle` for the boundaries the §1b hook
902
947
  // skipped (interruption, failure, steer-parked drains) or for builds
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).
@@ -59,13 +64,15 @@ export function assessReviewContent(content) {
59
64
  return "thin";
60
65
  return "present";
61
66
  }
62
- /** Guidance appended to thin/template summaries: what to write. */
67
+ /** Guidance appended to thin/template/stale summaries: what to write. */
63
68
  function reviewCadenceReminder() {
64
69
  return (`Before declaring done you must run the project's peer-review cadence: ` +
65
70
  `style-enforcer on the changed files, then test-grounder (evidence: tests that ` +
66
71
  `fail without the change, commands that actually pass), and code-reviewer / pattern-guardian ` +
67
72
  `for correctness and drift. Resolve every blocking finding, then write a summary of the ` +
68
73
  `review findings and their resolution to ${REVIEW_REL}.\n\n` +
74
+ `Do not re-run a specialist whose scope has not changed since its last report — ` +
75
+ `reuse that report and only re-run what your fixes invalidate.\n\n` +
69
76
  `Investigation-only reviewers: do not ask them to edit product code.`);
70
77
  }
71
78
  export function thinReviewMessage(changedFiles) {
@@ -86,3 +93,45 @@ export function templateReviewMessage(changedFiles) {
86
93
  `and resolutions, with every placeholder replaced by real findings.\n\n` +
87
94
  reviewCadenceReminder());
88
95
  }
96
+ /**
97
+ * Escape a literal for embedding in a RegExp.
98
+ */
99
+ function escapeRegExp(literal) {
100
+ return literal.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
101
+ }
102
+ /**
103
+ * Normalize a changed-file entry to the repo-relative `/`-separated form
104
+ * reviews are matched against. Tracker and git entries already arrive
105
+ * repo-relative; absolute entries under the project still match by
106
+ * relativizing, and separators normalize so Windows-style paths match.
107
+ */
108
+ export function normalizeReviewPath(file, directory) {
109
+ let rel = file;
110
+ if (rel.startsWith(directory) &&
111
+ (rel[directory.length] === "/" || rel[directory.length] === "\\")) {
112
+ rel = rel.slice(directory.length + 1);
113
+ }
114
+ return rel.replace(/\\/g, "/");
115
+ }
116
+ /**
117
+ * Changed files the review text does not cover (plan 18). A file counts as
118
+ * covered when the review names it — relative or absolute (absolute paths
119
+ * contain the relative form). Boundary-guarded so `b-a.ts` does not cover
120
+ * `a.ts` and `a.tsx` does not cover `a.ts`. Pure.
121
+ */
122
+ export function findUncoveredFiles(content, files) {
123
+ return files.filter((file) => {
124
+ const pattern = new RegExp(`(?<![\\w-])${escapeRegExp(file)}(?![\\w-])`);
125
+ return !pattern.test(content);
126
+ });
127
+ }
128
+ export function staleReviewMessage(changedFiles, uncovered) {
129
+ const files = changedFiles.map((f) => ` - ${f}`).join("\n");
130
+ const missing = uncovered.map((f) => ` - ${f}`).join("\n");
131
+ return (`opencode-dev-framework completion gate — the peer-review artifact is substantive ` +
132
+ `but stale: it does not cover this session's changes. Not mentioned:\n${missing}\n\n` +
133
+ `This session changed files:\n${files}\n\n` +
134
+ `Rewrite ${REVIEW_REL} fresh for THIS session's changes — scope, findings, ` +
135
+ `and resolutions, naming every file above.\n\n` +
136
+ reviewCadenceReminder());
137
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Shared per-project template-update flow: the `/df-update` server command
3
+ * brings a deployment's shipped files current with per-file approval.
4
+ *
5
+ * Detection runs in code (`statusTemplates` — the same comparison `df init`
6
+ * uses); diffing, presenting, and applying stay with the agent, which hands
7
+ * each drifted file to the user before touching it. There is no auto-apply
8
+ * path by construction. The user config (`.opencode-dev-framework.yml`) is
9
+ * structurally out of scope: it was never in the template set.
10
+ */
11
+ export interface TemplateDrift {
12
+ /** Shipped files present and identical. */
13
+ current: string[];
14
+ /** Shipped files present with different content — offer refresh. */
15
+ refresh: string[];
16
+ /** Shipped files absent — offer add (reads as botched/partial install). */
17
+ add: string[];
18
+ /** True when nothing is installed at all — redirect to `/df-init`. */
19
+ empty: boolean;
20
+ }
21
+ export declare function checkTemplateUpdates(directory: string): Promise<TemplateDrift>;
22
+ /**
23
+ * Compose the prompt text the `/df-update` command submits back to the
24
+ * session. An installed-but-current tree reports status; an empty tree
25
+ * redirects to `/df-init`; a drifted tree hands the agent the lists plus
26
+ * standing instructions (present per file, apply only what is approved).
27
+ */
28
+ export declare function composeUpdatePrompt(drift: TemplateDrift, directory: string): string;
29
+ export interface UpdateCommandDeps {
30
+ directory: string;
31
+ delivery: unknown;
32
+ /** Throws when the owning setup/state went stale mid-check. */
33
+ checkAlive: () => void;
34
+ /** Deliver the report to the session; throws on transport failure. */
35
+ deliver: (text: string, delivery: unknown) => Promise<void>;
36
+ }
37
+ /**
38
+ * Execute the `/df-update` command with injected dependencies (pure policy,
39
+ * testable without a plugin context). Check, re-check liveness across the
40
+ * await, then deliver. A delivery failure throws: the check succeeded, only
41
+ * the handoff back failed, and the message says how to recover.
42
+ */
43
+ export declare function runUpdateCommand(deps: UpdateCommandDeps): Promise<void>;
package/dist/update.js ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Shared per-project template-update flow: the `/df-update` server command
3
+ * brings a deployment's shipped files current with per-file approval.
4
+ *
5
+ * Detection runs in code (`statusTemplates` — the same comparison `df init`
6
+ * uses); diffing, presenting, and applying stay with the agent, which hands
7
+ * each drifted file to the user before touching it. There is no auto-apply
8
+ * path by construction. The user config (`.opencode-dev-framework.yml`) is
9
+ * structurally out of scope: it was never in the template set.
10
+ */
11
+ import { statusTemplates } from "./installer.js";
12
+ export async function checkTemplateUpdates(directory) {
13
+ const status = await statusTemplates(directory);
14
+ return {
15
+ current: status.present,
16
+ refresh: status.different,
17
+ add: status.missing,
18
+ empty: status.present.length === 0 && status.different.length === 0,
19
+ };
20
+ }
21
+ /**
22
+ * Compose the prompt text the `/df-update` command submits back to the
23
+ * session. An installed-but-current tree reports status; an empty tree
24
+ * redirects to `/df-init`; a drifted tree hands the agent the lists plus
25
+ * standing instructions (present per file, apply only what is approved).
26
+ */
27
+ export function composeUpdatePrompt(drift, directory) {
28
+ const total = drift.current.length + drift.refresh.length + drift.add.length;
29
+ if (drift.empty) {
30
+ return [
31
+ `No opencode-dev-framework templates are installed in ${directory}.`,
32
+ "Run /df-init for the full first-time setup instead of adding files piecemeal.",
33
+ ].join("\n");
34
+ }
35
+ if (drift.refresh.length === 0 && drift.add.length === 0) {
36
+ return [
37
+ `opencode-dev-framework templates in ${directory} are current: ` +
38
+ `${drift.current.length}/${total} shipped files match.`,
39
+ "Nothing to do.",
40
+ ].join("\n");
41
+ }
42
+ const lines = [
43
+ `opencode-dev-framework template drift in ${directory}: ` +
44
+ `${drift.current.length}/${total} current, ` +
45
+ `${drift.refresh.length} to refresh, ${drift.add.length} to add.`,
46
+ ];
47
+ if (drift.refresh.length > 0) {
48
+ lines.push("", "Refresh (differs from shipped):", ...drift.refresh.map((f) => `- ${f}`));
49
+ }
50
+ if (drift.add.length > 0) {
51
+ lines.push("", "Add (shipped, absent — likely a partial install):", ...drift.add.map((f) => `- ${f}`));
52
+ }
53
+ lines.push("", "Bring the deployment current from the lists above. For each refresh file, " +
54
+ "run diff yourself against the shipped template, present the per-file diff, " +
55
+ "and overwrite only what the user approves. For each add file, present what it " +
56
+ "is and add only what the user approves. Never touch " +
57
+ ".opencode-dev-framework.yml — it is user config, not a shipped template. " +
58
+ "Report what was applied and what was left alone.");
59
+ return lines.join("\n");
60
+ }
61
+ /**
62
+ * Execute the `/df-update` command with injected dependencies (pure policy,
63
+ * testable without a plugin context). Check, re-check liveness across the
64
+ * await, then deliver. A delivery failure throws: the check succeeded, only
65
+ * the handoff back failed, and the message says how to recover.
66
+ */
67
+ export async function runUpdateCommand(deps) {
68
+ const drift = await checkTemplateUpdates(deps.directory);
69
+ deps.checkAlive();
70
+ const text = composeUpdatePrompt(drift, deps.directory);
71
+ try {
72
+ await deps.deliver(text, deps.delivery);
73
+ }
74
+ catch (error) {
75
+ const detail = error instanceof Error ? error.message : String(error);
76
+ throw new Error(`df-update detected drift (${drift.refresh.length} to refresh, ${drift.add.length} to add) ` +
77
+ `but the handoff back to the session failed (${detail}); retry /df-update — it only reads, never writes.`);
78
+ }
79
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-dev-framework",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "OpenCode plugin that enforces project-specific quality gates during AI coding sessions",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -20,6 +20,10 @@ whenever the user asks for a review of the current changes.
20
20
 
21
21
  ## Steps
22
22
 
23
+ These steps are the orchestrator's. If you are running as one of the
24
+ specialist subagents below, do only your assigned step and report back —
25
+ never consolidate, fix, or re-run anything.
26
+
23
27
  1. **Scope the change.** Determine exactly what changed:
24
28
 
25
29
  ```bash
@@ -39,6 +43,9 @@ whenever the user asks for a review of the current changes.
39
43
  - **code-reviewer** — general correctness: bugs, logic errors, security,
40
44
  resource/concurrency issues. High bar, high signal only.
41
45
 
46
+ On a repeat pass, run only the specialists whose scope changed since
47
+ their last report — reuse fresh reports instead of running them again.
48
+
42
49
  If the `code-reviewer` agent is not installed in this project (or cannot be
43
50
  invoked in the current environment), perform that correctness pass yourself
44
51
  inline: read the diff in full, and for each changed file check for logic
@@ -52,8 +59,9 @@ whenever the user asks for a review of the current changes.
52
59
  now, or state precisely why it does not apply. Do not produce a report of
53
60
  issues you then leave unaddressed.
54
61
 
55
- 5. **Confirm.** Re-run the relevant specialist if you made non-trivial fixes,
56
- until no blocking items remain.
62
+ 5. **Confirm.** Re-run only the specialist relevant to what you fixed,
63
+ until no blocking items remain. Never restart the full set when a
64
+ single area changed — reuse the fresh reports.
57
65
 
58
66
  ## Output
59
67