opencode-dev-framework 1.9.0 → 1.9.1

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,7 +155,7 @@ 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
+ | `/df-update` | Server-side command: diffs installed templates against shipped, refresh/add each with user approval (detection only, never writes). Drift is also mentioned once at session startup. |
159
159
  | `/df-goal <objective>` | Server-side command: starts a **verified** native goal (requires native `/goal`, a blocking profile, and at least one real check). |
160
160
 
161
161
  The TUI commands open instantly and never feed the LLM; `/df-init`,
package/dist/index.js CHANGED
@@ -37,8 +37,10 @@ import { createLintLimiter, detectPreCommitAvailability, isLintFailure, lintFile
37
37
  import { createLogger } from "./logger.js";
38
38
  import { checkToolCall, extractFilePath, FILE_TOOLS, toPermissionGuard } from "./protect.js";
39
39
  import { constitutionPresent, loadConstitution } from "./rules.js";
40
+ import { clearSessionDirectory, hasSeenSessionStart, markSessionStartSeen } from "./registry.js";
40
41
  import { findRosterIndex, renderDutyRoster, rosterPresent } from "./roster.js";
41
42
  import { writeRuntimeStatus } from "./runtime-status.js";
43
+ import { checkTemplateUpdates, driftMentionLine } from "./update.js";
42
44
  import { snapshotEnforceable } from "./weakening.js";
43
45
  let activeState = null;
44
46
  let fallbackLog = async () => { };
@@ -360,6 +362,27 @@ const plugin = Plugin.define({
360
362
  await safeLog(state, "debug", "duty roster injected into system prompt");
361
363
  }
362
364
  }
365
+ // 1a) Startup template-drift mention — once per session, best-effort.
366
+ // First `context` sighting of a sessionID is session startup (plugin
367
+ // `setup()` has no session to mention into). Drifted installs get one
368
+ // line pointing at `/df-update`; current and empty trees stay silent.
369
+ // Never throws into prompt assembly; never writes.
370
+ const startupID = getEventSessionID(event);
371
+ if (startupID !== undefined && !hasSeenSessionStart(startupID)) {
372
+ markSessionStartSeen(startupID);
373
+ try {
374
+ const line = driftMentionLine(await checkTemplateUpdates(state.directory));
375
+ if (line !== null) {
376
+ event.system.push({ type: "text", text: line });
377
+ await safeLog(state, "debug", "template drift mentioned at session startup");
378
+ }
379
+ }
380
+ catch (error) {
381
+ await safeLog(state, "debug", "startup drift check failed silently", {
382
+ error: String(error),
383
+ });
384
+ }
385
+ }
363
386
  }));
364
387
  // Also hook other request kinds so the reminder is not missed on title/generate
365
388
  // (no-op if model doesn't need it; cheap)
@@ -960,12 +983,14 @@ const plugin = Plugin.define({
960
983
  const type = event.type;
961
984
  if (isSessionDeletedEvent(type)) {
962
985
  // session.deleted: cleanup block counts + stuck snapshots
963
- // (memory + storage) and the idle dedup stamp for the session.
986
+ // (memory + storage), the idle dedup stamp, and the startup
987
+ // registries (directory mapping + drift-mention seen-set).
964
988
  const sid = getEventSessionID(event);
965
989
  if (sid) {
966
990
  await state.blocks.clear(sid);
967
991
  await state.stuckSnapshots.clear(sid);
968
992
  state.lastIdleHandled.delete(sid);
993
+ clearSessionDirectory(sid);
969
994
  }
970
995
  continue;
971
996
  }
@@ -49,6 +49,8 @@ export declare function setSessionDirectory(sessionID: string, directory: string
49
49
  export declare function getDirectoryForSession(sessionID: string): string | null;
50
50
  /** Forget a session's directory mapping (called on `session.deleted`). */
51
51
  export declare function clearSessionDirectory(sessionID: string): void;
52
+ export declare function hasSeenSessionStart(sessionID: string): boolean;
53
+ export declare function markSessionStartSeen(sessionID: string): void;
52
54
  /** Reset all in-memory registries. Intended for test cleanup between
53
55
  * test runs so stale session-to-directory mappings do not bleed
54
56
  * `getStateForSession` into the next test. */
package/dist/registry.js CHANGED
@@ -54,15 +54,26 @@ export function setSessionDirectory(sessionID, directory) {
54
54
  export function getDirectoryForSession(sessionID) {
55
55
  return sessionToDirectory.get(sessionID) ?? null;
56
56
  }
57
+ /** Session IDs already given their startup mention. In-memory like the
58
+ * directory map, so an opencode restart/reload naturally re-arms it. */
59
+ const sessionStartSeen = new Set();
57
60
  /** Forget a session's directory mapping (called on `session.deleted`). */
58
61
  export function clearSessionDirectory(sessionID) {
59
62
  sessionToDirectory.delete(sessionID);
63
+ sessionStartSeen.delete(sessionID);
64
+ }
65
+ export function hasSeenSessionStart(sessionID) {
66
+ return sessionStartSeen.has(sessionID);
67
+ }
68
+ export function markSessionStartSeen(sessionID) {
69
+ sessionStartSeen.add(sessionID);
60
70
  }
61
71
  /** Reset all in-memory registries. Intended for test cleanup between
62
72
  * test runs so stale session-to-directory mappings do not bleed
63
73
  * `getStateForSession` into the next test. */
64
74
  export function resetRegistry() {
65
75
  sessionToDirectory.clear();
76
+ sessionStartSeen.clear();
66
77
  hookRegistry.clear();
67
78
  activeDirectory = null;
68
79
  }
package/dist/update.d.ts CHANGED
@@ -26,6 +26,13 @@ export declare function checkTemplateUpdates(directory: string): Promise<Templat
26
26
  * standing instructions (present per file, apply only what is approved).
27
27
  */
28
28
  export declare function composeUpdatePrompt(drift: TemplateDrift, directory: string): string;
29
+ /**
30
+ * One-line startup mention for template drift, or null when there is
31
+ * nothing to say. Installed-but-current and empty trees stay silent: the
32
+ * mention covers drift only (an empty tree is `/df-init` territory, and
33
+ * the command itself already redirects there — no new nag is invented).
34
+ */
35
+ export declare function driftMentionLine(drift: TemplateDrift): string | null;
29
36
  export interface UpdateCommandDeps {
30
37
  directory: string;
31
38
  delivery: unknown;
package/dist/update.js CHANGED
@@ -58,6 +58,26 @@ export function composeUpdatePrompt(drift, directory) {
58
58
  "Report what was applied and what was left alone.");
59
59
  return lines.join("\n");
60
60
  }
61
+ /**
62
+ * One-line startup mention for template drift, or null when there is
63
+ * nothing to say. Installed-but-current and empty trees stay silent: the
64
+ * mention covers drift only (an empty tree is `/df-init` territory, and
65
+ * the command itself already redirects there — no new nag is invented).
66
+ */
67
+ export function driftMentionLine(drift) {
68
+ if (drift.empty || (drift.refresh.length === 0 && drift.add.length === 0)) {
69
+ return null;
70
+ }
71
+ const parts = [];
72
+ if (drift.refresh.length > 0) {
73
+ parts.push(`${drift.refresh.length} to refresh`);
74
+ }
75
+ if (drift.add.length > 0) {
76
+ parts.push(`${drift.add.length} to add`);
77
+ }
78
+ return (`opencode-dev-framework templates have drifted (${parts.join(", ")}). ` +
79
+ "Run /df-update to review each file with approval.");
80
+ }
61
81
  /**
62
82
  * Execute the `/df-update` command with injected dependencies (pure policy,
63
83
  * testable without a plugin context). Check, re-check liveness across the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-dev-framework",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "OpenCode plugin that enforces project-specific quality gates during AI coding sessions",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,7 +22,10 @@ whenever the user asks for a review of the current changes.
22
22
 
23
23
  These steps are the orchestrator's. If you are running as one of the
24
24
  specialist subagents below, do only your assigned step and report back —
25
- never consolidate, fix, or re-run anything.
25
+ never consolidate, fix, or re-run anything. Only the orchestrator writes
26
+ the review artifact: as a specialist you never write files, your report
27
+ text is your entire output. This overrides any session duty telling you
28
+ to write the review file.
26
29
 
27
30
  1. **Scope the change.** Determine exactly what changed:
28
31