opencode-dev-framework 1.9.5 → 1.10.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 +137 -33
- package/bin/df +94 -4
- package/cordis.patch.yml +17 -0
- package/dist/adapters/dsh/extract.d.ts +47 -0
- package/dist/adapters/dsh/extract.js +62 -0
- package/dist/adapters/dsh/index.d.ts +332 -0
- package/dist/adapters/dsh/index.js +1643 -0
- package/dist/adapters/opencode/index.d.ts +30 -0
- package/dist/{index.js → adapters/opencode/index.js} +120 -235
- package/dist/{block-store.d.ts → core/block-store.d.ts} +10 -3
- package/dist/{commands.js → core/commands.js} +4 -2
- package/dist/{config.d.ts → core/config.d.ts} +16 -4
- package/dist/{config.js → core/config.js} +102 -10
- package/dist/{format-status.d.ts → core/format-status.d.ts} +13 -2
- package/dist/{format-status.js → core/format-status.js} +30 -7
- package/dist/{gate.d.ts → core/gate.d.ts} +9 -1
- package/dist/{gate.js → core/gate.js} +14 -2
- package/dist/{goal.d.ts → core/goal.d.ts} +4 -3
- package/dist/{goal.js → core/goal.js} +4 -3
- package/dist/{harness.d.ts → core/harness.d.ts} +10 -5
- package/dist/{harness.js → core/harness.js} +119 -32
- package/dist/{init.d.ts → core/init.d.ts} +18 -1
- package/dist/{init.js → core/init.js} +33 -8
- package/dist/core/install-dsh.d.ts +67 -0
- package/dist/core/install-dsh.js +235 -0
- package/dist/{installer.d.ts → core/installer.d.ts} +32 -2
- package/dist/{installer.js → core/installer.js} +129 -12
- package/dist/{lint.d.ts → core/lint.d.ts} +43 -2
- package/dist/{lint.js → core/lint.js} +89 -2
- package/dist/core/paths.d.ts +35 -0
- package/dist/core/paths.js +41 -0
- package/dist/{protect.d.ts → core/protect.d.ts} +18 -4
- package/dist/{protect.js → core/protect.js} +85 -34
- package/dist/{registry.d.ts → core/registry.d.ts} +9 -1
- package/dist/{review.js → core/review.js} +14 -6
- package/dist/{rules.d.ts → core/rules.d.ts} +3 -2
- package/dist/{rules.js → core/rules.js} +21 -5
- package/dist/core/run-hooks.d.ts +138 -0
- package/dist/core/run-hooks.js +196 -0
- package/dist/{runtime-status.d.ts → core/runtime-status.d.ts} +5 -4
- package/dist/{runtime-status.js → core/runtime-status.js} +29 -17
- package/dist/{types.d.ts → core/types.d.ts} +17 -0
- package/dist/{update.d.ts → core/update.d.ts} +12 -4
- package/dist/{update.js → core/update.js} +28 -12
- package/dist/{weakening.js → core/weakening.js} +2 -1
- package/package.json +16 -6
- package/rules/40-delegation.md +13 -2
- package/templates/.opencode/agents/style-enforcer.md +1 -1
- package/templates/.opencode/agents/test-grounder.md +1 -1
- package/templates/.opencode/skills/ground-in-tests/SKILL.md +1 -1
- package/templates/.opencode/skills/project-config/SKILL.md +2 -2
- package/tui.tsx +6 -6
- package/dist/index.d.ts +0 -101
- /package/dist/{block-store.js → core/block-store.js} +0 -0
- /package/dist/{command-utils.d.ts → core/command-utils.d.ts} +0 -0
- /package/dist/{command-utils.js → core/command-utils.js} +0 -0
- /package/dist/{commands.d.ts → core/commands.d.ts} +0 -0
- /package/dist/{detect.d.ts → core/detect.d.ts} +0 -0
- /package/dist/{detect.js → core/detect.js} +0 -0
- /package/dist/{host.d.ts → core/host.d.ts} +0 -0
- /package/dist/{host.js → core/host.js} +0 -0
- /package/dist/{logger.d.ts → core/logger.d.ts} +0 -0
- /package/dist/{logger.js → core/logger.js} +0 -0
- /package/dist/{registry.js → core/registry.js} +0 -0
- /package/dist/{review.d.ts → core/review.d.ts} +0 -0
- /package/dist/{roster.d.ts → core/roster.d.ts} +0 -0
- /package/dist/{roster.js → core/roster.js} +0 -0
- /package/dist/{types.js → core/types.js} +0 -0
- /package/dist/{weakening.d.ts → core/weakening.d.ts} +0 -0
- /package/templates/{.opencode/opencode-dev-framework → .dev-framework}/rules/.gitkeep +0 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared hook flow: harness-agnostic hook state and the per-edit / gate
|
|
3
|
+
* evaluation flows that every host adapter drives. Host-specific code
|
|
4
|
+
* (opencode `Plugin.define` registration, DSH Cordis bundle wiring) lives
|
|
5
|
+
* in the adapters and calls into these flows with a populated `HookState`.
|
|
6
|
+
*
|
|
7
|
+
* This module was extracted from the OpenCode adapter
|
|
8
|
+
* (`src/adapters/opencode/index.ts`, formerly `src/index.ts`) with
|
|
9
|
+
* relocation only — plus formatter line-breaks, added explicit types, and
|
|
10
|
+
* a `blockCounts` doc comment. No behavior change; the adapter keeps
|
|
11
|
+
* registration thin.
|
|
12
|
+
*/
|
|
13
|
+
import { clearConfigCache, configMtimeMs, loadConfig } from "./config.js";
|
|
14
|
+
import { evaluateCompletion } from "./harness.js";
|
|
15
|
+
import { detectPreCommitAvailability, isLintFailure, lintFile, summarizeLint, } from "./lint.js";
|
|
16
|
+
import { loadConstitution } from "./rules.js";
|
|
17
|
+
import { writeRuntimeStatus } from "./runtime-status.js";
|
|
18
|
+
import { checkTemplateUpdates, summarizeDrift } from "./update.js";
|
|
19
|
+
/**
|
|
20
|
+
* Live hook state for stale-hook guards. Private binding — read it via
|
|
21
|
+
* `getActiveState()` (writes go through `setActiveState`), mirroring the
|
|
22
|
+
* `registry.ts` getter/setter idiom. Never exported mutable: an ESM live
|
|
23
|
+
* `let` binding would let any importer assign past the setter.
|
|
24
|
+
*/
|
|
25
|
+
let activeState = null;
|
|
26
|
+
export function getActiveState() {
|
|
27
|
+
return activeState;
|
|
28
|
+
}
|
|
29
|
+
export function setActiveState(state) {
|
|
30
|
+
activeState = state;
|
|
31
|
+
}
|
|
32
|
+
/** Fallback logger before any adapter registers one. Same idiom as above. */
|
|
33
|
+
let fallbackLog = async () => { };
|
|
34
|
+
export function getFallbackLog() {
|
|
35
|
+
return fallbackLog;
|
|
36
|
+
}
|
|
37
|
+
export function setFallbackLog(log) {
|
|
38
|
+
fallbackLog = log;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Minimum interval between config-mtime checks. Every hook fire calls
|
|
42
|
+
* `reloadConfigIfChanged`, but the config file almost never changes
|
|
43
|
+
* mid-session, so a 1s staleness window is invisible.
|
|
44
|
+
*/
|
|
45
|
+
const CONFIG_RELOAD_MIN_INTERVAL_MS = 1000;
|
|
46
|
+
export function safeLog(state, level, message, extra) {
|
|
47
|
+
const fn = state && typeof state.log === "function" ? state.log : fallbackLog;
|
|
48
|
+
return fn(level, message, extra);
|
|
49
|
+
}
|
|
50
|
+
export async function reloadConfigIfChanged(state) {
|
|
51
|
+
// Throttle mtime checks: every hook fire calls this, but the config file
|
|
52
|
+
// almost never changes mid-session. A 1s staleness window is invisible.
|
|
53
|
+
const now = Date.now();
|
|
54
|
+
if (now - state.lastConfigCheck < CONFIG_RELOAD_MIN_INTERVAL_MS) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
state.lastConfigCheck = now;
|
|
58
|
+
const mtime = configMtimeMs(state.directory);
|
|
59
|
+
if (mtime === undefined) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (state.configMtime !== undefined && state.configMtime === mtime) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
clearConfigCache();
|
|
67
|
+
const next = loadConfig(state.directory);
|
|
68
|
+
const { constitution } = await loadConstitution(next, state.directory);
|
|
69
|
+
state.config = next;
|
|
70
|
+
state.constitution = constitution;
|
|
71
|
+
state.configMtime = mtime;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// keep current state on read failure
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Turn a completion verdict into the continuation message fed back to the
|
|
79
|
+
* agent when blocked. Shared by the `experimental.idle` hook (same
|
|
80
|
+
* execution, via synthetic) and the `event.subscribe` idle re-prompt
|
|
81
|
+
* fallback so wording (and block counting) is identical on every
|
|
82
|
+
* enforcement level.
|
|
83
|
+
*/
|
|
84
|
+
export function continuationMessage(verdict) {
|
|
85
|
+
const why = verdict.reason === "review"
|
|
86
|
+
? "the peer-review requirement is unmet"
|
|
87
|
+
: verdict.reason === "weakened"
|
|
88
|
+
? "the completion contract was weakened mid-session"
|
|
89
|
+
: "the repo's checks are failing";
|
|
90
|
+
return (`opencode-dev-framework completion gate blocked you from finishing because ${why} ` +
|
|
91
|
+
`(block ${verdict.blockCount}/${verdict.maxBlocks}).\n\n${verdict.summary}\n\n` +
|
|
92
|
+
`Fix the underlying cause and continue. Do NOT disable, skip, or weaken these checks to ` +
|
|
93
|
+
`get past the gate. If a failure is pre-existing and unrelated to your work, prove it ` +
|
|
94
|
+
`(show it fails on a clean tree) and report it to the user.\n\n` +
|
|
95
|
+
`You can inspect live gate state with dev_framework_runtime; if the setup ` +
|
|
96
|
+
`looks stale, check drift with dev_framework_update.`);
|
|
97
|
+
}
|
|
98
|
+
/** Log pass/standdown verdicts; returns the continuation message when blocked. */
|
|
99
|
+
export async function actOnVerdict(state, verdict) {
|
|
100
|
+
if (verdict.decision === "pass") {
|
|
101
|
+
if (verdict.note) {
|
|
102
|
+
await safeLog(state, "info", verdict.note, { changedFiles: verdict.changedFiles });
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
if (verdict.decision === "standdown") {
|
|
107
|
+
// evaluateCompletion already logged the stand-down loudly.
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
return continuationMessage(verdict);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Per-edit lint flow, shared by the `execute.after` hook (primary) and the
|
|
114
|
+
* `filesystem.changed` fallback. Skipped files log at debug; passes at info;
|
|
115
|
+
* failures log loudly at error (the edit already landed, so unlike
|
|
116
|
+
* `execute.before` this never throws — it only reports).
|
|
117
|
+
*/
|
|
118
|
+
export async function runPerEditLint(state, filePath) {
|
|
119
|
+
if (!state.config.on_edit.lint)
|
|
120
|
+
return;
|
|
121
|
+
if (state.config.precommit === "auto" && state.precommitAvailable === undefined) {
|
|
122
|
+
state.precommitAvailable = await detectPreCommitAvailability(state.run, state.directory);
|
|
123
|
+
}
|
|
124
|
+
const outcome = await state.lintLimiter.run(() => lintFile(state.run, state.config, filePath, {
|
|
125
|
+
cwd: state.directory,
|
|
126
|
+
timeout: state.config.gate?.timeout,
|
|
127
|
+
precommitAvailable: state.precommitAvailable,
|
|
128
|
+
}));
|
|
129
|
+
if (outcome.skipped) {
|
|
130
|
+
await safeLog(state, "debug", summarizeLint(outcome), {
|
|
131
|
+
filePath,
|
|
132
|
+
reason: outcome.reason,
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (!isLintFailure(outcome)) {
|
|
137
|
+
await safeLog(state, "info", summarizeLint(outcome), { filePath });
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
await safeLog(state, "error", summarizeLint(outcome), {
|
|
141
|
+
filePath,
|
|
142
|
+
command: outcome.command?.join(" "),
|
|
143
|
+
stdout: outcome.result?.stdout,
|
|
144
|
+
stderr: outcome.result?.stderr,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/** Assemble the completion verdict with the state's live dependencies. */
|
|
148
|
+
export function runCompletion(state, sessionID) {
|
|
149
|
+
return evaluateCompletion({
|
|
150
|
+
run: state.run,
|
|
151
|
+
config: state.config,
|
|
152
|
+
directory: state.directory,
|
|
153
|
+
sessionID,
|
|
154
|
+
tracker: state.tracker,
|
|
155
|
+
blockCounts: state.blocks,
|
|
156
|
+
stuckSnapshots: state.stuckSnapshots,
|
|
157
|
+
lintLimiter: state.lintLimiter,
|
|
158
|
+
passCache: state.passCache,
|
|
159
|
+
baseline: state.initialEnforceable,
|
|
160
|
+
log: (level, message, extra) => safeLog(state, level, message, extra),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Record a completed idle-hook evaluation for the dedup map. Stamp ONLY on
|
|
165
|
+
* the completed-evaluation paths (pass, blocked-admitted, standdown);
|
|
166
|
+
* throw/early-return paths must not stamp so the subscriber net retries.
|
|
167
|
+
*/
|
|
168
|
+
export function stampIdleHandled(state, sessionID) {
|
|
169
|
+
state.lastIdleHandled.set(sessionID, Date.now());
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Best-effort runtime snapshot for `/df-runtime`: hook state plus template
|
|
173
|
+
* drift, fire-and-forget (never throws, never blocks the caller).
|
|
174
|
+
*/
|
|
175
|
+
export function stampRuntimeStatus(directory, idleHookVia, continuation, skillMirrorRoot) {
|
|
176
|
+
void (async () => {
|
|
177
|
+
let templates;
|
|
178
|
+
try {
|
|
179
|
+
templates = summarizeDrift(await checkTemplateUpdates(directory, skillMirrorRoot));
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// Best-effort: the snapshot renders without template state.
|
|
183
|
+
}
|
|
184
|
+
await writeRuntimeStatus(directory, { idleHookVia, continuation, templates });
|
|
185
|
+
})();
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* True when the idle hook completed an evaluation for this session inside
|
|
189
|
+
* `windowMs`. The hook itself uses a short window (same-boundary
|
|
190
|
+
* double-fire guard for the dual key registration below); the subscriber
|
|
191
|
+
* net uses the full window (one boundary, one gate run).
|
|
192
|
+
*/
|
|
193
|
+
export function wasIdleHandledRecently(state, sessionID, windowMs = 5_000) {
|
|
194
|
+
const at = state.lastIdleHandled.get(sessionID);
|
|
195
|
+
return at !== undefined && Date.now() - at < windowMs;
|
|
196
|
+
}
|
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
* throws: a missing, corrupt, or stale snapshot renders as
|
|
9
9
|
* "not reported yet".
|
|
10
10
|
*/
|
|
11
|
+
import { RUNTIME_STATUS_FILE } from "./paths.js";
|
|
12
|
+
export { RUNTIME_STATUS_FILE };
|
|
11
13
|
/** Snapshot location, relative to the project directory. */
|
|
12
|
-
export declare const RUNTIME_STATUS_DIR = ".
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export type IdleHookVia = "experimental.idle" | "idle" | "none";
|
|
14
|
+
export declare const RUNTIME_STATUS_DIR = ".dev-framework";
|
|
15
|
+
/** Which session hook the core accepted, or neither (DSH uses `agent/turn-stopping`). */
|
|
16
|
+
export type IdleHookVia = "experimental.idle" | "idle" | "none" | "turn-stopping";
|
|
16
17
|
/** Dispatch history this session: hook-fired, net-fired, or neither yet. */
|
|
17
18
|
export type ContinuationState = "idle" | "fallback" | "armed";
|
|
18
19
|
/** Template drift state for the TUI `/df-runtime` command: up to date,
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
12
12
|
import { dirname, join } from "node:path";
|
|
13
13
|
import { fileURLToPath } from "node:url";
|
|
14
|
+
import { FRAMEWORK_DIR, RUNTIME_STATUS_FILE, RUNTIME_STATUS_RELS } from "./paths.js";
|
|
15
|
+
export { RUNTIME_STATUS_FILE };
|
|
14
16
|
/** Snapshot location, relative to the project directory. */
|
|
15
|
-
export const RUNTIME_STATUS_DIR =
|
|
16
|
-
export const RUNTIME_STATUS_FILE = "runtime-status.json";
|
|
17
|
+
export const RUNTIME_STATUS_DIR = FRAMEWORK_DIR;
|
|
17
18
|
export function snapshotPath(directory) {
|
|
18
19
|
return join(directory, RUNTIME_STATUS_DIR, RUNTIME_STATUS_FILE);
|
|
19
20
|
}
|
|
@@ -51,7 +52,10 @@ export async function writeRuntimeStatus(directory, partial) {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
function isIdleHookVia(value) {
|
|
54
|
-
return value === "experimental.idle" ||
|
|
55
|
+
return (value === "experimental.idle" ||
|
|
56
|
+
value === "idle" ||
|
|
57
|
+
value === "none" ||
|
|
58
|
+
value === "turn-stopping");
|
|
55
59
|
}
|
|
56
60
|
function isContinuationState(value) {
|
|
57
61
|
return value === "idle" || value === "fallback" || value === "armed";
|
|
@@ -67,20 +71,28 @@ function isTemplateState(value) {
|
|
|
67
71
|
typeof t.add === "number");
|
|
68
72
|
}
|
|
69
73
|
export async function readRuntimeStatus(directory) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
// New home first, previous home as fallback; writers use the new home
|
|
75
|
+
// only, so old snapshots fade with the next stamp.
|
|
76
|
+
const candidates = RUNTIME_STATUS_RELS.map((rel) => join(directory, rel));
|
|
77
|
+
for (const candidate of candidates) {
|
|
78
|
+
try {
|
|
79
|
+
const parsed = JSON.parse(await readFile(candidate, "utf8"));
|
|
80
|
+
if (typeof parsed.frameworkVersion !== "string" || typeof parsed.updatedAt !== "string") {
|
|
81
|
+
// Valid JSON, wrong shape: fall through to the legacy home
|
|
82
|
+
// rather than letting an invalid new snapshot shadow valid data.
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
frameworkVersion: parsed.frameworkVersion,
|
|
87
|
+
idleHookVia: isIdleHookVia(parsed.idleHookVia) ? parsed.idleHookVia : "none",
|
|
88
|
+
continuation: isContinuationState(parsed.continuation) ? parsed.continuation : "armed",
|
|
89
|
+
...(isTemplateState(parsed.templates) ? { templates: parsed.templates } : {}),
|
|
90
|
+
updatedAt: parsed.updatedAt,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// try the next (legacy) location
|
|
74
95
|
}
|
|
75
|
-
return {
|
|
76
|
-
frameworkVersion: parsed.frameworkVersion,
|
|
77
|
-
idleHookVia: isIdleHookVia(parsed.idleHookVia) ? parsed.idleHookVia : "none",
|
|
78
|
-
continuation: isContinuationState(parsed.continuation) ? parsed.continuation : "armed",
|
|
79
|
-
...(isTemplateState(parsed.templates) ? { templates: parsed.templates } : {}),
|
|
80
|
-
updatedAt: parsed.updatedAt,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return null;
|
|
85
96
|
}
|
|
97
|
+
return null;
|
|
86
98
|
}
|
|
@@ -6,6 +6,23 @@
|
|
|
6
6
|
export type Profile = "off" | "advisory" | "standard" | "strict";
|
|
7
7
|
export type ProtectMode = "warn" | "deny";
|
|
8
8
|
export type GateScope = "all" | "changed";
|
|
9
|
+
/**
|
|
10
|
+
* Host seam availability, probed once at mount with guarded reads and
|
|
11
|
+
* rendered by status so a degraded mount reads as degraded. Shared named
|
|
12
|
+
* type so the forked `HookState` definitions (`registry.ts`,
|
|
13
|
+
* `run-hooks.ts`) cannot skew: one shape, two references.
|
|
14
|
+
*/
|
|
15
|
+
export interface HostSeams {
|
|
16
|
+
tools: boolean;
|
|
17
|
+
goals: boolean;
|
|
18
|
+
approval: boolean;
|
|
19
|
+
/** DSH-only: the host subagent service (specialist dispatch). */
|
|
20
|
+
subagents: boolean;
|
|
21
|
+
/** DSH-only: the agent-preset registry (read-only reviewer preset). */
|
|
22
|
+
agentPresets: boolean;
|
|
23
|
+
/** DSH-only: the session-history query service (continuity probe). */
|
|
24
|
+
sessionQuery: boolean;
|
|
25
|
+
}
|
|
9
26
|
/**
|
|
10
27
|
* A command specification: either a single default command string, or a map
|
|
11
28
|
* of per-extension overrides keyed by extension (e.g. `.go`).
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* Detection runs in code (`statusTemplates` — the same comparison `df init`
|
|
6
6
|
* uses); diffing, presenting, and applying stay with the agent, which hands
|
|
7
7
|
* each drifted file to the user before touching it. There is no auto-apply
|
|
8
|
-
* path by construction. The user config (`.
|
|
9
|
-
* structurally out of scope: it was never
|
|
8
|
+
* path by construction. The user config (`.dev-framework.yml`, or the legacy
|
|
9
|
+
* `.opencode-dev-framework.yml`) is structurally out of scope: it was never
|
|
10
|
+
* in the template set.
|
|
10
11
|
*/
|
|
11
12
|
import type { TemplateState } from "./runtime-status.js";
|
|
12
13
|
export interface TemplateDrift {
|
|
@@ -16,10 +17,11 @@ export interface TemplateDrift {
|
|
|
16
17
|
refresh: string[];
|
|
17
18
|
/** Shipped files absent — offer add (reads as botched/partial install). */
|
|
18
19
|
add: string[];
|
|
19
|
-
/** True when
|
|
20
|
+
/** True when no templates are installed at all — redirect to `/df-init`.
|
|
21
|
+
* Mirror copies never count: they are derived output, not the install. */
|
|
20
22
|
empty: boolean;
|
|
21
23
|
}
|
|
22
|
-
export declare function checkTemplateUpdates(directory: string): Promise<TemplateDrift>;
|
|
24
|
+
export declare function checkTemplateUpdates(directory: string, skillMirrorRoot?: string): Promise<TemplateDrift>;
|
|
23
25
|
/**
|
|
24
26
|
* Compose the prompt text the `/df-update` command submits back to the
|
|
25
27
|
* session. An installed-but-current tree reports status; an empty tree
|
|
@@ -53,6 +55,12 @@ export declare function driftMentionLine(drift: TemplateDrift): string | null;
|
|
|
53
55
|
export interface UpdateCommandDeps {
|
|
54
56
|
directory: string;
|
|
55
57
|
delivery: unknown;
|
|
58
|
+
/**
|
|
59
|
+
* Skill mirror root to include in drift (same capability as
|
|
60
|
+
* `skillMirrorRoot` on the init side). Unset: drift covers the
|
|
61
|
+
* template set only.
|
|
62
|
+
*/
|
|
63
|
+
skillMirrorRoot?: string;
|
|
56
64
|
/** Throws when the owning setup/state went stale mid-check. */
|
|
57
65
|
checkAlive: () => void;
|
|
58
66
|
/** Deliver the report to the session; throws on transport failure. */
|
|
@@ -5,18 +5,33 @@
|
|
|
5
5
|
* Detection runs in code (`statusTemplates` — the same comparison `df init`
|
|
6
6
|
* uses); diffing, presenting, and applying stay with the agent, which hands
|
|
7
7
|
* each drifted file to the user before touching it. There is no auto-apply
|
|
8
|
-
* path by construction. The user config (`.
|
|
9
|
-
* structurally out of scope: it was never
|
|
8
|
+
* path by construction. The user config (`.dev-framework.yml`, or the legacy
|
|
9
|
+
* `.opencode-dev-framework.yml`) is structurally out of scope: it was never
|
|
10
|
+
* in the template set.
|
|
10
11
|
*/
|
|
11
|
-
import { statusTemplates } from "./installer.js";
|
|
12
|
-
export async function checkTemplateUpdates(directory) {
|
|
12
|
+
import { statusMirror, statusTemplates } from "./installer.js";
|
|
13
|
+
export async function checkTemplateUpdates(directory, skillMirrorRoot) {
|
|
13
14
|
const status = await statusTemplates(directory);
|
|
14
|
-
|
|
15
|
-
current: status.present,
|
|
16
|
-
refresh: status.different,
|
|
17
|
-
add: status.missing,
|
|
15
|
+
const drift = {
|
|
16
|
+
current: [...status.present],
|
|
17
|
+
refresh: [...status.different],
|
|
18
|
+
add: [...status.missing],
|
|
19
|
+
// Deliberately template-only: the mirror is derived output, not the
|
|
20
|
+
// install. A populated mirror must never mask missing templates and
|
|
21
|
+
// suppress the /df-init redirect — an unloadable setup with no
|
|
22
|
+
// templates needs reinstalling, not mirror diffing.
|
|
18
23
|
empty: status.present.length === 0 && status.different.length === 0,
|
|
19
24
|
};
|
|
25
|
+
// Mirror maintenance: a host-scanned skill copy that is missing or
|
|
26
|
+
// edited-out-of-sync leaves the setup unloadable, so it reads as drift
|
|
27
|
+
// exactly like a template file. Unset means no mirror to maintain.
|
|
28
|
+
if (skillMirrorRoot !== undefined) {
|
|
29
|
+
const mirror = await statusMirror(directory, skillMirrorRoot);
|
|
30
|
+
drift.current.push(...mirror.present);
|
|
31
|
+
drift.refresh.push(...mirror.different);
|
|
32
|
+
drift.add.push(...mirror.missing);
|
|
33
|
+
}
|
|
34
|
+
return drift;
|
|
20
35
|
}
|
|
21
36
|
/**
|
|
22
37
|
* Compose the prompt text the `/df-update` command submits back to the
|
|
@@ -53,8 +68,9 @@ export function composeUpdatePrompt(drift, directory) {
|
|
|
53
68
|
lines.push("", "Bring the deployment current from the lists above. For each refresh file, " +
|
|
54
69
|
"run diff yourself against the shipped template, present the per-file diff, " +
|
|
55
70
|
"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
|
|
71
|
+
"is and add only what the user approves. Never touch the config file " +
|
|
72
|
+
"(`.dev-framework.yml`, or legacy `.opencode-dev-framework.yml`) — it is user " +
|
|
73
|
+
"config, not a shipped template. " +
|
|
58
74
|
"Report what was applied and what was left alone.");
|
|
59
75
|
return lines.join("\n");
|
|
60
76
|
}
|
|
@@ -109,7 +125,7 @@ export function driftMentionLine(drift) {
|
|
|
109
125
|
parts.push(`${drift.add.length} to add`);
|
|
110
126
|
}
|
|
111
127
|
return (`opencode-dev-framework templates have drifted (${parts.join(", ")}). ` +
|
|
112
|
-
"Run
|
|
128
|
+
"Run dev_framework_update to review each file with approval.");
|
|
113
129
|
}
|
|
114
130
|
/**
|
|
115
131
|
* Execute the `/df-update` command with injected dependencies (pure policy,
|
|
@@ -122,7 +138,7 @@ export function driftMentionLine(drift) {
|
|
|
122
138
|
* recover. Returns whether the handoff was delivered.
|
|
123
139
|
*/
|
|
124
140
|
export async function runUpdateCommand(deps) {
|
|
125
|
-
const drift = await checkTemplateUpdates(deps.directory);
|
|
141
|
+
const drift = await checkTemplateUpdates(deps.directory, deps.skillMirrorRoot);
|
|
126
142
|
deps.checkAlive();
|
|
127
143
|
if (!needsAgentHandoff(drift)) {
|
|
128
144
|
return false;
|
|
@@ -2,7 +2,8 @@ import { normalizeCommandMap } from "./command-utils.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Config-weakening detection (plan 17 §2).
|
|
4
4
|
*
|
|
5
|
-
* The duties document (`.
|
|
5
|
+
* The duties document (`.dev-framework.yml`, or the legacy
|
|
6
|
+
* `.opencode-dev-framework.yml`) is freely rewritable
|
|
6
7
|
* mid-session and reloads on mtime — deleting checks, dropping
|
|
7
8
|
* `require_review`, or lowering `max_blocks` silently moves the goalposts.
|
|
8
9
|
* Rewriting the duties to make them pass is the canonical duty-escape, so
|
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-dev-framework",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "OpenCode plugin that enforces project-specific quality gates during AI coding sessions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"main": "dist/index.js",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
7
|
+
"main": "dist/adapters/opencode/index.js",
|
|
8
|
+
"types": "dist/adapters/opencode/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js"
|
|
11
|
+
"types": "./dist/adapters/opencode/index.d.ts",
|
|
12
|
+
"import": "./dist/adapters/opencode/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./dsh": {
|
|
15
|
+
"types": "./dist/adapters/dsh/index.d.ts",
|
|
16
|
+
"import": "./dist/adapters/dsh/index.js"
|
|
13
17
|
},
|
|
14
18
|
"./tui": {
|
|
15
19
|
"types": "./dist/tui.d.ts",
|
|
@@ -25,7 +29,8 @@
|
|
|
25
29
|
"bin",
|
|
26
30
|
"rules",
|
|
27
31
|
"templates",
|
|
28
|
-
"tui.tsx"
|
|
32
|
+
"tui.tsx",
|
|
33
|
+
"cordis.patch.yml"
|
|
29
34
|
],
|
|
30
35
|
"bin": {
|
|
31
36
|
"df": "bin/df"
|
|
@@ -74,5 +79,10 @@
|
|
|
74
79
|
"solid-js": "^1.9.12",
|
|
75
80
|
"typescript": "^7.0.2",
|
|
76
81
|
"vitest": "^4.1.10"
|
|
82
|
+
},
|
|
83
|
+
"dsh": {
|
|
84
|
+
"bundle": {
|
|
85
|
+
"patch": "./cordis.patch.yml"
|
|
86
|
+
}
|
|
77
87
|
}
|
|
78
88
|
}
|
package/rules/40-delegation.md
CHANGED
|
@@ -4,6 +4,17 @@ When the framework is active, you are not a lone coder; you are the lead enginee
|
|
|
4
4
|
coordinating specialist reviewers. Use them as a continuous loop, not a final
|
|
5
5
|
rubber-stamp. Catching issues early is cheaper than catching them at the gate.
|
|
6
6
|
|
|
7
|
+
## Harness rule (read first)
|
|
8
|
+
|
|
9
|
+
- **On OpenCode**, the specialists below are runnable subagents (installed
|
|
10
|
+
under `.opencode/agents/`). Delegate to them per the cadence.
|
|
11
|
+
- **On DSH**, the adapter dispatches `pattern-guardian`, `style-enforcer`,
|
|
12
|
+
and `code-reviewer` as read-only child sessions at review-blocks when the
|
|
13
|
+
host subagent seam is available, then folds their findings into the
|
|
14
|
+
blocking feedback. `test-grounder` remains an inline lead duty. When the
|
|
15
|
+
dispatch seam is absent, run the same checks inline via the skills, at the
|
|
16
|
+
same bar, and record each pass and its outcome in the review artifact.
|
|
17
|
+
|
|
7
18
|
## The specialists
|
|
8
19
|
|
|
9
20
|
When the project has the specialist agents installed (under `.opencode/agents/`),
|
|
@@ -47,8 +58,8 @@ change you plan first, implement from the plan without expanding scope, then
|
|
|
47
58
|
harden (full verification + review + fresh artifact) before declaring done.
|
|
48
59
|
Keep delegation proportional: a one-line fix doesn't need the full loop; a new module
|
|
49
60
|
does. Use judgment, but never skip the test-grounding and review steps for behavioral
|
|
50
|
-
changes. If
|
|
51
|
-
checks yourself with the skills in this section.
|
|
61
|
+
changes. If specialist agents or DSH dispatch are unavailable, perform the same
|
|
62
|
+
checks yourself with the skills in this section (see the harness rule above).
|
|
52
63
|
|
|
53
64
|
## Execute plans under `/df-goal`
|
|
54
65
|
|
|
@@ -18,7 +18,7 @@ written by one careful author.
|
|
|
18
18
|
Given a set of changed files, check them against — in priority order:
|
|
19
19
|
|
|
20
20
|
1. **An explicit project style guide**, if one exists. Look for it at the path
|
|
21
|
-
named in `.
|
|
21
|
+
named in `.dev-framework.yml` (`style_guide:`), or common
|
|
22
22
|
locations: `STYLE.md`, `STYLEGUIDE.md`, `docs/style*.md`, `CONTRIBUTING.md`,
|
|
23
23
|
`.editorconfig`, and lint configs (`.eslintrc*`, `ruff.toml`,
|
|
24
24
|
`.rubocop.yml`, `pyproject.toml`, etc.).
|
|
@@ -38,7 +38,7 @@ running the project's real commands and reading the output.
|
|
|
38
38
|
## How to work
|
|
39
39
|
|
|
40
40
|
1. Determine the change scope (git diff) and what was claimed.
|
|
41
|
-
2. Discover the project's commands: from `.
|
|
41
|
+
2. Discover the project's commands: from `.dev-framework.yml`
|
|
42
42
|
(`commands.test`, `commands.typecheck`) if present, else from
|
|
43
43
|
`package.json` scripts, `pyproject.toml`/`pytest`, `go test`, `Cargo.toml`,
|
|
44
44
|
`Makefile`, etc.
|
|
@@ -18,7 +18,7 @@ you're about to make a claim about behavior you have not actually executed.
|
|
|
18
18
|
|
|
19
19
|
## Steps
|
|
20
20
|
|
|
21
|
-
1. **Discover the commands.** Prefer `.
|
|
21
|
+
1. **Discover the commands.** Prefer `.dev-framework.yml`
|
|
22
22
|
(`commands.test`, `commands.typecheck`). Else detect from the project
|
|
23
23
|
(`package.json` scripts, `pytest`, `go test ./...`, `cargo test`,
|
|
24
24
|
`Makefile`). If the project genuinely has no tests, say so explicitly and
|
|
@@ -15,7 +15,7 @@ build system, not guessed. You propose; the user disposes.
|
|
|
15
15
|
## When to use
|
|
16
16
|
|
|
17
17
|
Setting up the plugin on a project for the first time, instead of
|
|
18
|
-
hand-writing `.
|
|
18
|
+
hand-writing `.dev-framework.yml` or trusting `df init`
|
|
19
19
|
detection alone. Also when the existing config smells wrong — gate
|
|
20
20
|
passing vacuously, commands that don't match CI, a red tree nobody can
|
|
21
21
|
explain.
|
|
@@ -87,7 +87,7 @@ list assumptions.
|
|
|
87
87
|
|
|
88
88
|
## Output
|
|
89
89
|
|
|
90
|
-
+ The proposed `.
|
|
90
|
+
+ The proposed `.dev-framework.yml` and `.dev-framework/hardening.md` content
|
|
91
91
|
as a reviewable diff, each command annotated verified-by-running,
|
|
92
92
|
inferred-from-files, or needs-confirmation.
|
|
93
93
|
+ The enforceability self-check result (blocking profile + at least one
|
package/tui.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** @jsxImportSource @opentui/solid */
|
|
2
2
|
|
|
3
3
|
import { Plugin } from "@opencode/plugin/tui";
|
|
4
|
-
import { changeProfile, verifyGate } from "./dist/commands.js";
|
|
5
|
-
import { loadConfig } from "./dist/config.js";
|
|
6
|
-
import { runCommand } from "./dist/host.js";
|
|
7
|
-
import { renderConfigStatus, renderHelp, renderRuntimeStatus } from "./dist/format-status.js";
|
|
8
|
-
import { readRuntimeStatus } from "./dist/runtime-status.js";
|
|
9
|
-
import type { Profile } from "./dist/types.js";
|
|
4
|
+
import { changeProfile, verifyGate } from "./dist/core/commands.js";
|
|
5
|
+
import { loadConfig } from "./dist/core/config.js";
|
|
6
|
+
import { runCommand } from "./dist/core/host.js";
|
|
7
|
+
import { renderConfigStatus, renderHelp, renderRuntimeStatus } from "./dist/core/format-status.js";
|
|
8
|
+
import { readRuntimeStatus } from "./dist/core/runtime-status.js";
|
|
9
|
+
import type { Profile } from "./dist/core/types.js";
|
|
10
10
|
|
|
11
11
|
const PROFILES: Profile[] = ["off", "advisory", "standard", "strict"];
|
|
12
12
|
|