opencode-dev-framework 1.8.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
@@ -155,10 +155,11 @@ How each layer is enforced, and what it honestly cannot do:
155
155
  | `/df-profile` | Instant modal picker (or `/df-profile <name>`): switches profile now, written to config. |
156
156
  | `/df-verify` | Runs the verification suite manually; pass/fail summary in a modal. |
157
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 TUI commands open instantly and never feed the LLM; `/df-init` and
161
- `/df-goal` are server-side and drive the session. 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)
@@ -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.js CHANGED
@@ -178,6 +178,8 @@ function reviewMissingMessage(changedFiles) {
178
178
  `fail without the change, commands that actually pass), and code-reviewer / pattern-guardian ` +
179
179
  `for correctness and drift. Resolve every blocking finding, then write a summary of the ` +
180
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` +
181
183
  `Investigation-only reviewers: do not ask them to edit product code.`);
182
184
  }
183
185
  /** Create an empty pass cache (one per session state). */
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.js CHANGED
@@ -64,13 +64,15 @@ export function assessReviewContent(content) {
64
64
  return "thin";
65
65
  return "present";
66
66
  }
67
- /** Guidance appended to thin/template summaries: what to write. */
67
+ /** Guidance appended to thin/template/stale summaries: what to write. */
68
68
  function reviewCadenceReminder() {
69
69
  return (`Before declaring done you must run the project's peer-review cadence: ` +
70
70
  `style-enforcer on the changed files, then test-grounder (evidence: tests that ` +
71
71
  `fail without the change, commands that actually pass), and code-reviewer / pattern-guardian ` +
72
72
  `for correctness and drift. Resolve every blocking finding, then write a summary of the ` +
73
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` +
74
76
  `Investigation-only reviewers: do not ask them to edit product code.`);
75
77
  }
76
78
  export function thinReviewMessage(changedFiles) {
@@ -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.8.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