opencode-dev-framework 1.11.0 → 1.12.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 +38 -12
- package/dist/adapters/dsh/extract.js +2 -2
- package/dist/adapters/dsh/index.d.ts +71 -0
- package/dist/adapters/dsh/index.js +129 -8
- package/dist/adapters/opencode/index.js +2 -3
- package/dist/core/config.js +3 -3
- package/dist/core/install-dsh.js +1 -1
- package/dist/core/logger.d.ts +3 -21
- package/dist/core/logger.js +3 -24
- package/package.json +1 -1
- package/rules/10-quality-bar.md +5 -0
- package/templates/.opencode/agents/code-reviewer.md +7 -1
- package/templates/.opencode/agents/pattern-guardian.md +7 -1
- package/templates/.opencode/agents/style-enforcer.md +7 -1
- package/templates/.opencode/agents/test-grounder.md +4 -1
- package/templates/.opencode/skills/project-config/SKILL.md +6 -1
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
[](https://dsh-plugin.org/plugins/jwitmann/opencode-dev-framework) [](https://opencode.ai/docs/plugins/) [](https://www.npmjs.com/package/opencode-dev-framework) [](https://github.com/jwitmann/opencode-dev-framework/actions) [](https://github.com/jwitmann/opencode-dev-framework/blob/main/LICENSE)
|
|
4
4
|
|
|
5
5
|
AI agents can say they're done without proving it. This plugin replaces
|
|
6
|
-
assertion with evidence: guardrails, per-edit
|
|
6
|
+
assertion with evidence: guardrails, per-edit lint feedback (and formatting
|
|
7
|
+
on DSH, where the host provides none),
|
|
7
8
|
a completion gate that runs your real checks, and verified goals that require
|
|
8
9
|
a tool-result PASS on the final tree. Exit codes don't negotiate.
|
|
9
10
|
|
|
@@ -17,6 +18,16 @@ Inspired by
|
|
|
17
18
|
which supports Copilot CLI, Claude Code, and Codex CLI; this is an independent
|
|
18
19
|
implementation. DSH guide: [`docs/user/dsh.md`](docs/user/dsh.md).
|
|
19
20
|
|
|
21
|
+
## Principles
|
|
22
|
+
|
|
23
|
+
These principles guide every mechanism in this plugin:
|
|
24
|
+
|
|
25
|
+
- **Verbatim evidence.** Work is judged as performed — original output or explicitly marked pointers, never silently rewritten. No output redaction, no revised reports, no laundered context.
|
|
26
|
+
- **Read-only reviewers.** The judging party cannot touch the work. Findings are reported visibly; rework happens in the open, and the gate re-verifies from scratch.
|
|
27
|
+
- **Reveal, don't sanitize.** Audit trails over hidden rewrites — what happened stays inspectable.
|
|
28
|
+
- **No bypass-required measures.** Nothing that fights legitimate use; if a control needs a workaround, it's the control that's wrong.
|
|
29
|
+
- **Bounded and loud.** Enforcement budgets are explicit and stand-down is announced, never a quiet pass.
|
|
30
|
+
|
|
20
31
|
## Quickstart
|
|
21
32
|
|
|
22
33
|
Five minutes from zero to your first gated session.
|
|
@@ -25,7 +36,7 @@ Five minutes from zero to your first gated session.
|
|
|
25
36
|
|
|
26
37
|
**On OpenCode:**
|
|
27
38
|
|
|
28
|
-
Requires OpenCode `v2.x` (live-verified on `v2.0.26` and `v2.2.0`).
|
|
39
|
+
Requires OpenCode `v2.x` (live-verified on `v2.0.26` and `v2.2.0`). V1 agent frontmatter and the V1 plugin API are deprecated upstream and unsupported — agent names come from filenames.
|
|
29
40
|
|
|
30
41
|
```bash
|
|
31
42
|
opencode plugin add opencode-dev-framework
|
|
@@ -36,12 +47,14 @@ Or declare it in `opencode.json`:
|
|
|
36
47
|
```json
|
|
37
48
|
{
|
|
38
49
|
"$schema": "https://opencode.ai/config.json",
|
|
39
|
-
"
|
|
50
|
+
"plugins": ["opencode-dev-framework"]
|
|
40
51
|
}
|
|
41
52
|
```
|
|
42
53
|
|
|
43
54
|
**On DSH:**
|
|
44
55
|
|
|
56
|
+
Requires DSH `0.2.2-rc.3` or newer (live-verified on `0.2.2-rc.5`).
|
|
57
|
+
|
|
45
58
|
```bash
|
|
46
59
|
dsh plugin --profile <name> add opencode-dev-framework
|
|
47
60
|
df install-dsh --profile <name> # preset seam + verification
|
|
@@ -69,14 +82,14 @@ scripted runs (add `--dsh` on DSH so the host-visible skill mirror is
|
|
|
69
82
|
scaffolded too):
|
|
70
83
|
|
|
71
84
|
```bash
|
|
72
|
-
npx
|
|
85
|
+
npx opencode-dev-framework init [--dsh]
|
|
73
86
|
```
|
|
74
87
|
|
|
75
88
|
Conflicts need `--overwrite-existing` or `--skip-existing` — everything
|
|
76
|
-
else is under `npx
|
|
89
|
+
else is under `npx opencode-dev-framework --help`.
|
|
77
90
|
|
|
78
91
|
On DSH, run `dsh` from the project root (or export `ODF_WORKDIR`), and
|
|
79
|
-
accept template drift via
|
|
92
|
+
accept template drift via `/df-update` if the session reports any.
|
|
80
93
|
|
|
81
94
|
Then ask the agent for a small edit. You will see the plugin working: the
|
|
82
95
|
edit is checked against guardrails before it lands, your linter runs on the
|
|
@@ -112,7 +125,7 @@ differ. Neither harness is the "real" one; each is stronger somewhere:
|
|
|
112
125
|
| Redirect targets (`a > file`) | Not guard-checked | **Guard-checked** (wider than OpenCode) |
|
|
113
126
|
| denial identity | Reason text | Reason text + structured `{name, code}` |
|
|
114
127
|
| Skills | `.opencode/skills` (native) | `.dsh/skills` (installed by `df-init`, kept current by `df-update`) |
|
|
115
|
-
| Reviewer agents | `.opencode/agents` specialists run as subagents | **Adapter-dispatched DSH children on review-blocks** (one per kind; read-only preset where the registry exists; findings fold into the steer; customize via `.dev-framework/agents/`); inline steer when the seam is absent |
|
|
128
|
+
| Reviewer agents | `.opencode/agents` specialists run as subagents (least-privilege `permissions` frontmatter: no edits, no shell except test-grounder) | **Adapter-dispatched DSH children on review-blocks** (one per kind; read-only preset where the registry exists; findings fold into the steer; customize via `.dev-framework/agents/`); inline steer when the seam is absent |
|
|
116
129
|
| Goals | `/df-goal` wraps native `/goal` | `df-goal` creates the host goal with the same verification contract |
|
|
117
130
|
| Install | One command (`opencode plugin add`) | `dsh plugin add` + `df install-dsh` (bundle auto-wires the base entry) |
|
|
118
131
|
| Review UI | Instant TUI modals, never feed the LLM | Host commands returning text |
|
|
@@ -136,11 +149,14 @@ semantics, block budgeting, `protect_off` scope, and all eight
|
|
|
136
149
|
at session start (bundled default, overridable per project).
|
|
137
150
|
- **Guardrails.** Blocks or warns on protected paths (`.env`, vendored
|
|
138
151
|
code, your own globs) and dangerous shell commands (`git push`, `rm -rf`).
|
|
152
|
+
Secrets are blocked at the write, never scrubbed from sight —
|
|
153
|
+
[secret handling](docs/user/enforcement.md#secrets) recommends gitleaks
|
|
154
|
+
at the commit boundary.
|
|
139
155
|
- **Per-edit lint.** Runs your linter on each edited file. On OpenCode
|
|
140
156
|
the result is logged against the landed edit; on DSH a finding fails
|
|
141
157
|
the tool call so the agent retries clean in the same turn.
|
|
142
158
|
- **Completion gate.** At the would-go-idle boundary, runs typecheck, tests,
|
|
143
|
-
acceptance checks, and (
|
|
159
|
+
acceptance checks, and (in `strict`, lint on changed files) — plus a required
|
|
144
160
|
substantive peer-review artifact in `standard`/`strict` (length floors, no
|
|
145
161
|
template checkboxes, written after the latest session edit). On OpenCode, failures steer the session back via a
|
|
146
162
|
synthetic continuation, bounded by `gate.max_blocks` (fewer when
|
|
@@ -182,6 +198,10 @@ synthetic continuation); on DSH the same verdict bites earlier — the
|
|
|
182
198
|
pre-terminal completion block, same-turn lint `block`s, and dispatched
|
|
183
199
|
reviewers above all run inside the turn instead of round-tripping through it:
|
|
184
200
|
|
|
201
|
+

|
|
202
|
+
|
|
203
|
+
Text version of the same diagram (identical content, for text-mode readers):
|
|
204
|
+
|
|
185
205
|
```text
|
|
186
206
|
user prompt
|
|
187
207
|
(plain or /df-goal plan)
|
|
@@ -220,8 +240,10 @@ wrappers (dotted lines in the diagram version):
|
|
|
220
240
|
native /goal ── wraps the loop, drives turns ──> agent implements
|
|
221
241
|
```
|
|
222
242
|
|
|
223
|
-
|
|
224
|
-
|
|
243
|
+
Flow source lives in [`docs/user/enforcement.md`](docs/user/enforcement.md#flow)
|
|
244
|
+
as mermaid; `docs/assets/flow.svg` is rendered from it
|
|
245
|
+
(`npx @mermaid-js/mermaid-cli -i <mermaid> -o docs/assets/flow.svg`) and
|
|
246
|
+
embedded above by absolute URL so it renders on npm too — update all three
|
|
225
247
|
together.
|
|
226
248
|
|
|
227
249
|
## Profiles
|
|
@@ -266,8 +288,12 @@ of modals. Full reference:
|
|
|
266
288
|
from the bounded completion mechanisms below.
|
|
267
289
|
- A cached pass never survives a restart — after a restart the gate
|
|
268
290
|
always re-verifies the final tree from scratch.
|
|
269
|
-
- Formatting and linting
|
|
270
|
-
|
|
291
|
+
- Formatting and linting use your project tooling — the framework never
|
|
292
|
+
reimplements them. On OpenCode the host runs the formatter; on DSH the
|
|
293
|
+
adapter runs your configured formatter command before linting. Want
|
|
294
|
+
formatting on OpenCode? Configure the host `formatter` in
|
|
295
|
+
`opencode.json` ([docs](https://opencode.ai/docs/formatters/)) — the
|
|
296
|
+
plugin defers to it and never runs its own.
|
|
271
297
|
|
|
272
298
|
### OpenCode
|
|
273
299
|
|
|
@@ -27,7 +27,7 @@ export function extractDshPaths(exec) {
|
|
|
27
27
|
typeof args === "object" &&
|
|
28
28
|
args !== null) {
|
|
29
29
|
const record = args;
|
|
30
|
-
const snake = record
|
|
30
|
+
const snake = record.file_path;
|
|
31
31
|
if (typeof snake === "string" && snake !== "") {
|
|
32
32
|
return [snake];
|
|
33
33
|
}
|
|
@@ -38,7 +38,7 @@ export function extractDshPaths(exec) {
|
|
|
38
38
|
return [];
|
|
39
39
|
}
|
|
40
40
|
if (exec.name === "apply_patch" && typeof args === "object" && args !== null) {
|
|
41
|
-
const input = args
|
|
41
|
+
const input = args.input;
|
|
42
42
|
if (typeof input !== "string") {
|
|
43
43
|
return [];
|
|
44
44
|
}
|
|
@@ -149,6 +149,19 @@ export interface DshAgentPresets {
|
|
|
149
149
|
export interface DshSubagents {
|
|
150
150
|
getProvider(name: string): {
|
|
151
151
|
name: string;
|
|
152
|
+
/**
|
|
153
|
+
* Start-request capabilities the provider honors. Read once per
|
|
154
|
+
* dispatch (plan 27): the host rejects a request needing an
|
|
155
|
+
* unsupported capability, so the adapter only sends what the
|
|
156
|
+
* provider for this start supports. Absent on older hosts —
|
|
157
|
+
* absence degrades to the capability-less (text-only) path.
|
|
158
|
+
*/
|
|
159
|
+
capabilities?: {
|
|
160
|
+
agentOptions?: boolean;
|
|
161
|
+
agentPreset?: boolean;
|
|
162
|
+
outputSchema?: boolean;
|
|
163
|
+
depthLimit?: boolean;
|
|
164
|
+
};
|
|
152
165
|
} | undefined;
|
|
153
166
|
resolveMaxDepth(value: unknown): unknown;
|
|
154
167
|
startActivation(request: {
|
|
@@ -161,6 +174,12 @@ export interface DshSubagents {
|
|
|
161
174
|
}>;
|
|
162
175
|
parent: unknown;
|
|
163
176
|
agentPreset?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Structured-findings schema (plan 27): object-rooted, within the
|
|
179
|
+
* host's enforced subset. Sent only after a positive capability
|
|
180
|
+
* probe — the host rejects the start otherwise.
|
|
181
|
+
*/
|
|
182
|
+
outputSchema?: unknown;
|
|
164
183
|
maxDepth?: unknown;
|
|
165
184
|
signal?: AbortSignal;
|
|
166
185
|
delivery: "parent";
|
|
@@ -322,6 +341,58 @@ export declare function lintBlockLines(outcomes: LintOutcome[]): string[];
|
|
|
322
341
|
* as top-level — the pre-existing behavior, never a new block.
|
|
323
342
|
*/
|
|
324
343
|
export declare function isChildAgent(agent: DshAgent | DshExec["agent"] | undefined): boolean;
|
|
344
|
+
/**
|
|
345
|
+
* Structured-findings schema (plan 27): what a specialist child reports
|
|
346
|
+
* through the host's capture tool when the provider supports
|
|
347
|
+
* `outputSchema`. Object-rooted and keyword-minimal (`type` / `properties`
|
|
348
|
+
* / `required` / `additionalProperties` / `items` / `enum`) so it stays
|
|
349
|
+
* inside the host's enforced subset — the host rejects the start
|
|
350
|
+
* otherwise. Closed (`additionalProperties: false`) so a drifting child
|
|
351
|
+
* fails validation loudly instead of smuggling extra fields past the
|
|
352
|
+
* fold.
|
|
353
|
+
*/
|
|
354
|
+
export declare const SPECIALIST_FINDINGS_SCHEMA: {
|
|
355
|
+
readonly type: "object";
|
|
356
|
+
readonly properties: {
|
|
357
|
+
readonly summary: {
|
|
358
|
+
readonly type: "string";
|
|
359
|
+
};
|
|
360
|
+
readonly findings: {
|
|
361
|
+
readonly type: "array";
|
|
362
|
+
readonly items: {
|
|
363
|
+
readonly type: "object";
|
|
364
|
+
readonly properties: {
|
|
365
|
+
readonly file: {
|
|
366
|
+
readonly type: "string";
|
|
367
|
+
};
|
|
368
|
+
readonly line: {
|
|
369
|
+
readonly type: "integer";
|
|
370
|
+
};
|
|
371
|
+
readonly issue: {
|
|
372
|
+
readonly type: "string";
|
|
373
|
+
};
|
|
374
|
+
readonly severity: {
|
|
375
|
+
readonly type: "string";
|
|
376
|
+
readonly enum: readonly ["blocking", "should-fix", "note"];
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
readonly required: readonly ["file", "issue", "severity"];
|
|
380
|
+
readonly additionalProperties: false;
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
readonly required: readonly ["summary", "findings"];
|
|
385
|
+
readonly additionalProperties: false;
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* Structured findings out of one entering text, or null. Prefers the
|
|
389
|
+
* host-rendered `Structured result:` block (exact JSON the child
|
|
390
|
+
* submitted, already schema-validated by the provider). Malformed JSON,
|
|
391
|
+
* wrong shape, or zero usable entries all return null so the caller
|
|
392
|
+
* falls back to the closing-message regex — structure is an upgrade,
|
|
393
|
+
* never a new failure mode.
|
|
394
|
+
*/
|
|
395
|
+
export declare function extractStructuredFindings(text: string): string[] | null;
|
|
325
396
|
/**
|
|
326
397
|
* Register the ODF gates on a DSH Cordis context. Synchronous like every
|
|
327
398
|
* DSH plugin `apply`. A project without (or with a broken) config gets no
|
|
@@ -58,7 +58,7 @@ function odfInfo(code) {
|
|
|
58
58
|
}
|
|
59
59
|
/** Resolve the project directory: explicit env override, else process cwd. */
|
|
60
60
|
export function resolveDshDirectory(env = process.env) {
|
|
61
|
-
const override = env
|
|
61
|
+
const override = env.ODF_WORKDIR;
|
|
62
62
|
if (typeof override === "string" && override !== "") {
|
|
63
63
|
return override;
|
|
64
64
|
}
|
|
@@ -487,6 +487,103 @@ function reviewerPresetDefinition() {
|
|
|
487
487
|
* closing message.
|
|
488
488
|
*/
|
|
489
489
|
const SPECIALIST_NOTICE_RE = /Background subagent ([a-z0-9][a-z0-9-]*) finished[\s\S]*?[Ii]ts closing message:\s*([\s\S]*?)\s*$/;
|
|
490
|
+
/**
|
|
491
|
+
* Structured-findings schema (plan 27): what a specialist child reports
|
|
492
|
+
* through the host's capture tool when the provider supports
|
|
493
|
+
* `outputSchema`. Object-rooted and keyword-minimal (`type` / `properties`
|
|
494
|
+
* / `required` / `additionalProperties` / `items` / `enum`) so it stays
|
|
495
|
+
* inside the host's enforced subset — the host rejects the start
|
|
496
|
+
* otherwise. Closed (`additionalProperties: false`) so a drifting child
|
|
497
|
+
* fails validation loudly instead of smuggling extra fields past the
|
|
498
|
+
* fold.
|
|
499
|
+
*/
|
|
500
|
+
export const SPECIALIST_FINDINGS_SCHEMA = {
|
|
501
|
+
type: "object",
|
|
502
|
+
properties: {
|
|
503
|
+
summary: { type: "string" },
|
|
504
|
+
findings: {
|
|
505
|
+
type: "array",
|
|
506
|
+
items: {
|
|
507
|
+
type: "object",
|
|
508
|
+
properties: {
|
|
509
|
+
file: { type: "string" },
|
|
510
|
+
line: { type: "integer" },
|
|
511
|
+
issue: { type: "string" },
|
|
512
|
+
severity: { type: "string", enum: ["blocking", "should-fix", "note"] },
|
|
513
|
+
},
|
|
514
|
+
required: ["file", "issue", "severity"],
|
|
515
|
+
additionalProperties: false,
|
|
516
|
+
},
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
required: ["summary", "findings"],
|
|
520
|
+
additionalProperties: false,
|
|
521
|
+
};
|
|
522
|
+
/** Notice-block prefix the host prepends to a satisfied structured result. */
|
|
523
|
+
const SPECIALIST_STRUCTURED_RESULT_PREFIX = "Structured result:";
|
|
524
|
+
/** Severities the fold accepts; anything else is coerced to `note` (see below). */
|
|
525
|
+
const SPECIALIST_FINDING_SEVERITIES = new Set(["blocking", "should-fix", "note"]);
|
|
526
|
+
/** Maximum structured findings folded into one steer; the tail names the rest. */
|
|
527
|
+
const MAX_STRUCTURED_FINDINGS = 20;
|
|
528
|
+
/** Maximum folded summary length; longer summaries are truncated, not dropped. */
|
|
529
|
+
const MAX_STRUCTURED_SUMMARY_CHARS = 2000;
|
|
530
|
+
/**
|
|
531
|
+
* Structured findings out of one entering text, or null. Prefers the
|
|
532
|
+
* host-rendered `Structured result:` block (exact JSON the child
|
|
533
|
+
* submitted, already schema-validated by the provider). Malformed JSON,
|
|
534
|
+
* wrong shape, or zero usable entries all return null so the caller
|
|
535
|
+
* falls back to the closing-message regex — structure is an upgrade,
|
|
536
|
+
* never a new failure mode.
|
|
537
|
+
*/
|
|
538
|
+
export function extractStructuredFindings(text) {
|
|
539
|
+
const at = text.indexOf(SPECIALIST_STRUCTURED_RESULT_PREFIX);
|
|
540
|
+
if (at === -1) {
|
|
541
|
+
return null;
|
|
542
|
+
}
|
|
543
|
+
let parsed;
|
|
544
|
+
try {
|
|
545
|
+
parsed = JSON.parse(text.slice(at + SPECIALIST_STRUCTURED_RESULT_PREFIX.length).trim());
|
|
546
|
+
}
|
|
547
|
+
catch {
|
|
548
|
+
return null;
|
|
549
|
+
}
|
|
550
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
551
|
+
return null;
|
|
552
|
+
}
|
|
553
|
+
const { summary, findings } = parsed;
|
|
554
|
+
if (typeof summary !== "string" || !Array.isArray(findings)) {
|
|
555
|
+
return null;
|
|
556
|
+
}
|
|
557
|
+
const lines = [];
|
|
558
|
+
for (const entry of findings) {
|
|
559
|
+
if (typeof entry !== "object" || entry === null) {
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
const { file, line, issue, severity } = entry;
|
|
563
|
+
if (typeof file !== "string" || file === "" || typeof issue !== "string" || issue === "") {
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
// Unknown severities coerce to `note` rather than dropping the entry:
|
|
567
|
+
// a typo must never silently lose a finding, and the gate still blocks
|
|
568
|
+
// on the missing review artifact, so nothing is smuggled past enforcement.
|
|
569
|
+
const level = typeof severity === "string" && SPECIALIST_FINDING_SEVERITIES.has(severity)
|
|
570
|
+
? severity
|
|
571
|
+
: "note";
|
|
572
|
+
const where = typeof line === "number" && Number.isInteger(line) && line >= 1 ? `:${line}` : "";
|
|
573
|
+
lines.push(`- [${file}${where}] ${issue} (${level})`);
|
|
574
|
+
}
|
|
575
|
+
if (lines.length === 0) {
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
const headline = summary.trim() === "" ? "(no summary)" : summary.trim().slice(0, MAX_STRUCTURED_SUMMARY_CHARS);
|
|
579
|
+
const folded = [`${headline}`, ...lines];
|
|
580
|
+
if (lines.length > MAX_STRUCTURED_FINDINGS) {
|
|
581
|
+
const kept = lines.slice(0, MAX_STRUCTURED_FINDINGS);
|
|
582
|
+
const omitted = lines.length - MAX_STRUCTURED_FINDINGS;
|
|
583
|
+
return [`${headline}`, ...kept, `(findings omitted for ${omitted} more entries)`];
|
|
584
|
+
}
|
|
585
|
+
return folded;
|
|
586
|
+
}
|
|
490
587
|
/** Read-only investigation brief when the agent file is unreadable. */
|
|
491
588
|
const SPECIALIST_FALLBACK_BRIEF = "You are the pattern-guardian: check the changed files below against the " +
|
|
492
589
|
"codebase's existing patterns (duplication, re-invented helpers, divergent " +
|
|
@@ -694,6 +791,18 @@ export function apply(ctx) {
|
|
|
694
791
|
if (typeof subagents?.startActivation !== "function") {
|
|
695
792
|
return null;
|
|
696
793
|
}
|
|
794
|
+
// Capability probe (plan 27): `outputSchema` is per-provider — the
|
|
795
|
+
// host rejects a start that needs an unsupported capability, so probe
|
|
796
|
+
// the exact provider this start will use and degrade to the
|
|
797
|
+
// closing-text path on any doubt (absent seam, unknown provider,
|
|
798
|
+
// throwing probe). Never throws out of dispatch.
|
|
799
|
+
let structuredCapable = false;
|
|
800
|
+
try {
|
|
801
|
+
structuredCapable = subagents.getProvider("spawn")?.capabilities?.outputSchema === true;
|
|
802
|
+
}
|
|
803
|
+
catch {
|
|
804
|
+
structuredCapable = false;
|
|
805
|
+
}
|
|
697
806
|
try {
|
|
698
807
|
specialistCounter += 1;
|
|
699
808
|
const name = `${SPECIALIST_NAME_STEMS[kind]}-${specialistCounter}`;
|
|
@@ -701,7 +810,11 @@ export function apply(ctx) {
|
|
|
701
810
|
const prompt = `${brief}\n\nYou are investigating, not implementing: report findings ` +
|
|
702
811
|
`as text, do not edit anything.\nChanged files under review:\n` +
|
|
703
812
|
`${changedFiles.map((file) => `- ${file}`).join("\n")}\n\n` +
|
|
704
|
-
`Gate summary for this block:\n${gateSummary}
|
|
813
|
+
`Gate summary for this block:\n${gateSummary}` +
|
|
814
|
+
(structuredCapable
|
|
815
|
+
? `\n\nAlso report each finding with the structured-output tool ` +
|
|
816
|
+
`(one entry per finding), then close with a short text summary as usual.`
|
|
817
|
+
: "");
|
|
705
818
|
const activation = await subagents.startActivation({
|
|
706
819
|
provider: "spawn",
|
|
707
820
|
label: `odf specialist review (${kind})`,
|
|
@@ -709,11 +822,12 @@ export function apply(ctx) {
|
|
|
709
822
|
prompt: [{ type: "text", text: prompt }],
|
|
710
823
|
parent: agent,
|
|
711
824
|
...(reviewerPresetReady ? { agentPreset: REVIEWER_PRESET_ID } : {}),
|
|
825
|
+
...(structuredCapable ? { outputSchema: SPECIALIST_FINDINGS_SCHEMA } : {}),
|
|
712
826
|
...(signal !== undefined ? { signal } : {}),
|
|
713
827
|
delivery: "parent",
|
|
714
828
|
});
|
|
715
829
|
trackSpecialist(sessionKey, kind, activation.name);
|
|
716
|
-
await safeLog(state, "info", `specialist dispatched: ${activation.name}`, {
|
|
830
|
+
await safeLog(state, "info", `specialist dispatched: ${activation.name} (${structuredCapable ? "structured" : "text"} findings)`, {
|
|
717
831
|
sessionID: sessionKey,
|
|
718
832
|
});
|
|
719
833
|
return activation.name;
|
|
@@ -734,7 +848,7 @@ export function apply(ctx) {
|
|
|
734
848
|
}
|
|
735
849
|
const paths = extractDshPaths(exec);
|
|
736
850
|
const rawInput = typeof exec.arguments === "object" && exec.arguments !== null
|
|
737
|
-
? exec.arguments
|
|
851
|
+
? exec.arguments.input
|
|
738
852
|
: undefined;
|
|
739
853
|
warnApplyPatchSkip(state, exec, rawInput, paths);
|
|
740
854
|
// Children never write the parent's review artifact. Not a
|
|
@@ -870,7 +984,7 @@ export function apply(ctx) {
|
|
|
870
984
|
}
|
|
871
985
|
const execArgs = exec.arguments;
|
|
872
986
|
const rawInput = typeof execArgs === "object" && execArgs !== null
|
|
873
|
-
? execArgs
|
|
987
|
+
? execArgs.input
|
|
874
988
|
: undefined;
|
|
875
989
|
warnApplyPatchSkip(state, exec, rawInput, paths);
|
|
876
990
|
if (state.config.precommit === "auto" && state.precommitAvailable === undefined) {
|
|
@@ -1015,11 +1129,18 @@ export function apply(ctx) {
|
|
|
1015
1129
|
}
|
|
1016
1130
|
}
|
|
1017
1131
|
const finding = (match[2] ?? "").trim();
|
|
1018
|
-
|
|
1132
|
+
// Structured first (plan 27): when the child satisfied its
|
|
1133
|
+
// output schema, the notice carries a `Structured result:`
|
|
1134
|
+
// block — exact submitted JSON beats the quoted closing prose.
|
|
1135
|
+
// Null (absent/malformed/empty) falls back to the closing
|
|
1136
|
+
// text, preserving the pre-structured behavior verbatim.
|
|
1137
|
+
const structuredLines = extractStructuredFindings(text);
|
|
1138
|
+
const folded = structuredLines ?? (finding !== "" ? [finding] : []);
|
|
1139
|
+
if (folded.length > 0) {
|
|
1019
1140
|
const collected = specialistFindings.get(key) ?? [];
|
|
1020
|
-
collected.push(`[${finished}] ${
|
|
1141
|
+
collected.push(`[${finished}] ${structuredLines !== null ? "(structured) " : ""}${folded.join("\n")}`);
|
|
1021
1142
|
specialistFindings.set(key, collected);
|
|
1022
|
-
await safeLog(state, "info", `specialist findings collected: ${finished}`, {
|
|
1143
|
+
await safeLog(state, "info", `specialist findings collected: ${finished} (${structuredLines !== null ? "structured" : "text"})`, {
|
|
1023
1144
|
sessionID: key,
|
|
1024
1145
|
});
|
|
1025
1146
|
}
|
|
@@ -127,7 +127,6 @@ const plugin = Plugin.define({
|
|
|
127
127
|
catch (error) {
|
|
128
128
|
const message = error instanceof Error ? error.message : String(error);
|
|
129
129
|
await log("error", message, { directory });
|
|
130
|
-
// No client.app.log in V2 — stderr is enough
|
|
131
130
|
return;
|
|
132
131
|
}
|
|
133
132
|
const { constitution, warning } = await loadConstitution(config, directory);
|
|
@@ -196,7 +195,7 @@ const plugin = Plugin.define({
|
|
|
196
195
|
// the stale hook must NOT double-enforce), and (c) teardown racing
|
|
197
196
|
// an in-flight handler between awaits (captured `state` stays valid
|
|
198
197
|
// while the global may be cleared). See issue #1 follow-up.
|
|
199
|
-
// 1) Constitution injection — per model request (
|
|
198
|
+
// 1) Constitution injection — per model request (session.hook("context", ...))
|
|
200
199
|
trackRegistration(await ctx.session.hook("context", async (event) => {
|
|
201
200
|
if (getActiveState() !== state)
|
|
202
201
|
return;
|
|
@@ -501,7 +500,7 @@ const plugin = Plugin.define({
|
|
|
501
500
|
catch {
|
|
502
501
|
await safeLog(state, "warn", "could not register permission.evaluate hook; guardrails use execute.before only");
|
|
503
502
|
}
|
|
504
|
-
// 2) Guardrails — tool execution blocking (
|
|
503
|
+
// 2) Guardrails — tool execution blocking (ctx.tool.hook("execute.before", ...))
|
|
505
504
|
// Stale-hook fail-open: the closure captures its own `state` and allows
|
|
506
505
|
// the call whenever it is no longer live — torn down (activeState null)
|
|
507
506
|
// or superseded by a newer setup (activeState is a different instance,
|
package/dist/core/config.js
CHANGED
|
@@ -515,9 +515,9 @@ function selectConfigRecord(configPath, asRecord) {
|
|
|
515
515
|
return asRecord;
|
|
516
516
|
}
|
|
517
517
|
const nativeHit = NATIVE_OBJECT_KEYS.some((key) => keys.includes(key)) ||
|
|
518
|
-
(typeof asRecord
|
|
519
|
-
asRecord
|
|
520
|
-
!Array.isArray(asRecord
|
|
518
|
+
(typeof asRecord.rules === "object" &&
|
|
519
|
+
asRecord.rules !== null &&
|
|
520
|
+
!Array.isArray(asRecord.rules));
|
|
521
521
|
if (!nativeHit) {
|
|
522
522
|
return mapFlatConfig(asRecord);
|
|
523
523
|
}
|
package/dist/core/install-dsh.js
CHANGED
|
@@ -16,7 +16,7 @@ export const ODF_MANAGED_END = "# END odf-gates";
|
|
|
16
16
|
/** Seams every profile provides. `agentPresets` joins only where detected. */
|
|
17
17
|
export const ODF_BASE_SEAMS = ["tools", "goals", "approval", "subagents"];
|
|
18
18
|
export function resolveDshHome(explicit) {
|
|
19
|
-
const fromEnv = process.env
|
|
19
|
+
const fromEnv = process.env.DSH_HOME;
|
|
20
20
|
return (explicit ?? (typeof fromEnv === "string" && fromEnv !== "" ? fromEnv : join(homedir(), ".dsh")));
|
|
21
21
|
}
|
|
22
22
|
/** Probe one composed dump for preset-registry presence AND an
|
package/dist/core/logger.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Structured logging wrapper.
|
|
2
|
+
* Structured logging wrapper. Logs to stderr and the user-level log file.
|
|
3
3
|
*/
|
|
4
4
|
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
5
5
|
export declare const LOG_SERVICE = "opencode-dev-framework";
|
|
@@ -13,18 +13,6 @@ export declare const LOG_FILE_NAME = "opencode-dev-framework.log";
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const MAX_LOG_BYTES: number;
|
|
15
15
|
export type LogFn = (level: LogLevel, message: string, extra?: Record<string, unknown>) => Promise<void>;
|
|
16
|
-
type V1Client = {
|
|
17
|
-
app?: {
|
|
18
|
-
log?: (args: {
|
|
19
|
-
body: {
|
|
20
|
-
service: string;
|
|
21
|
-
level: LogLevel;
|
|
22
|
-
message: string;
|
|
23
|
-
extra?: Record<string, unknown>;
|
|
24
|
-
};
|
|
25
|
-
}) => Promise<unknown>;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
16
|
export interface LogPathInput {
|
|
29
17
|
platform?: string;
|
|
30
18
|
env?: Record<string, string | undefined>;
|
|
@@ -48,12 +36,6 @@ export declare function resolveDefaultLogFile(input?: LogPathInput): string | nu
|
|
|
48
36
|
*/
|
|
49
37
|
export declare function rotateLogFile(filePath: string, maxBytes: number): Promise<void>;
|
|
50
38
|
/**
|
|
51
|
-
* Create a logger.
|
|
52
|
-
* (as tests expect). Otherwise logs to stderr/file (V2 runtime).
|
|
39
|
+
* Create a logger. Writes to stderr and the user-level log file.
|
|
53
40
|
*/
|
|
54
|
-
export declare function createLogger(
|
|
55
|
-
app: {
|
|
56
|
-
log: (...args: unknown[]) => Promise<unknown>;
|
|
57
|
-
};
|
|
58
|
-
}): LogFn;
|
|
59
|
-
export {};
|
|
41
|
+
export declare function createLogger(): LogFn;
|
package/dist/core/logger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Structured logging wrapper.
|
|
2
|
+
* Structured logging wrapper. Logs to stderr and the user-level log file.
|
|
3
3
|
*/
|
|
4
4
|
import { appendFile, mkdir, rename, rm, stat } from "node:fs/promises";
|
|
5
5
|
import { homedir, tmpdir } from "node:os";
|
|
@@ -126,10 +126,9 @@ export async function rotateLogFile(filePath, maxBytes) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
|
-
* Create a logger.
|
|
130
|
-
* (as tests expect). Otherwise logs to stderr/file (V2 runtime).
|
|
129
|
+
* Create a logger. Writes to stderr and the user-level log file.
|
|
131
130
|
*/
|
|
132
|
-
export function createLogger(
|
|
131
|
+
export function createLogger() {
|
|
133
132
|
// Explicit override wins (empty string disables file logging:
|
|
134
133
|
// the falsy filePath below skips all writes); otherwise a
|
|
135
134
|
// user-level default so the "loud" record exists without
|
|
@@ -147,26 +146,6 @@ export function createLogger(client) {
|
|
|
147
146
|
message,
|
|
148
147
|
extra,
|
|
149
148
|
});
|
|
150
|
-
if (client?.app?.log) {
|
|
151
|
-
try {
|
|
152
|
-
// biome-ignore lint/style/noNonNullAssertion: guarded by if above
|
|
153
|
-
await client.app.log({
|
|
154
|
-
body: { service: LOG_SERVICE, level, message, extra },
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
catch (error) {
|
|
158
|
-
try {
|
|
159
|
-
process.stderr.write(`[${LOG_SERVICE}] ${level} ${message} (app.log failed: ${String(error)})\n`);
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
// ignore
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (filePath) {
|
|
166
|
-
await appendLogFile(filePath, line);
|
|
167
|
-
}
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
149
|
try {
|
|
171
150
|
process.stderr.write(`[${LOG_SERVICE}] ${level} ${message}\n`);
|
|
172
151
|
if (extra && Object.keys(extra).length > 0) {
|
package/package.json
CHANGED
package/rules/10-quality-bar.md
CHANGED
|
@@ -35,6 +35,11 @@ A task is done only when:
|
|
|
35
35
|
review file left over from a previous task; rewrite it fresh every time.
|
|
36
36
|
- You ran the project's full verification yourself (not just the completion
|
|
37
37
|
gate) and read the output — the gate is a backstop, not your test run.
|
|
38
|
+
- Duties before summary: refresh any required review artifact and run the
|
|
39
|
+
project's verification BEFORE writing the final summary — never summarize
|
|
40
|
+
work the gate hasn't cleared yet. The summary is the last thing you write
|
|
41
|
+
in the turn; a gate block and its remediation work land below it and bury
|
|
42
|
+
it out of view.
|
|
38
43
|
|
|
39
44
|
If you cannot meet the bar, stop and tell the user what is blocking you rather than
|
|
40
45
|
declaring success.
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: code-reviewer
|
|
3
2
|
mode: subagent
|
|
3
|
+
permissions:
|
|
4
|
+
- action: edit
|
|
5
|
+
resource: "*"
|
|
6
|
+
effect: deny
|
|
7
|
+
- action: shell
|
|
8
|
+
resource: "*"
|
|
9
|
+
effect: deny
|
|
4
10
|
description: >
|
|
5
11
|
Correctness reviewer. Scans changed code for bugs, logic errors, security
|
|
6
12
|
issues, and unsafe edge cases — independent of style and pattern concerns.
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: pattern-guardian
|
|
3
2
|
mode: subagent
|
|
3
|
+
permissions:
|
|
4
|
+
- action: edit
|
|
5
|
+
resource: "*"
|
|
6
|
+
effect: deny
|
|
7
|
+
- action: shell
|
|
8
|
+
resource: "*"
|
|
9
|
+
effect: deny
|
|
4
10
|
description: >
|
|
5
11
|
Anti-drift reviewer. Checks new or changed code against the patterns already
|
|
6
12
|
established in this codebase and flags duplication, re-invented helpers,
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: style-enforcer
|
|
3
2
|
mode: subagent
|
|
3
|
+
permissions:
|
|
4
|
+
- action: edit
|
|
5
|
+
resource: "*"
|
|
6
|
+
effect: deny
|
|
7
|
+
- action: shell
|
|
8
|
+
resource: "*"
|
|
9
|
+
effect: deny
|
|
4
10
|
description: >
|
|
5
11
|
Style-guide reviewer. Checks changed files against the project's documented
|
|
6
12
|
style guide (and, in its absence, the conventions of the surrounding code):
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: test-grounder
|
|
3
2
|
mode: subagent
|
|
3
|
+
permissions:
|
|
4
|
+
- action: edit
|
|
5
|
+
resource: "*"
|
|
6
|
+
effect: deny
|
|
4
7
|
description: >
|
|
5
8
|
Evidence auditor. Verifies that claims about a change are backed by reality:
|
|
6
9
|
that new behavior has a test which fails without the change and passes with
|
|
@@ -55,7 +55,12 @@ list assumptions.
|
|
|
55
55
|
looking for: the full verification command(s), per-language
|
|
56
56
|
lint/format invocations, integration tests with special needs (docker,
|
|
57
57
|
network, credentials), generated assets and how they rebuild, and
|
|
58
|
-
paths that must never be edited.
|
|
58
|
+
paths that must never be edited. Also check the formatting split: on
|
|
59
|
+
OpenCode the host owns formatting — if the project's `opencode.json`
|
|
60
|
+
declares no `formatter` but the project has formatter tooling
|
|
61
|
+
(Prettier, Biome, rustfmt, gofmt, …), flag adding one (the plugin
|
|
62
|
+
defers to it and never runs its own). On DSH there is nothing to
|
|
63
|
+
flag — the adapter runs the project's formatter itself.
|
|
59
64
|
|
|
60
65
|
2. **Prefer wrappers over bare tools.** If the project verifies via
|
|
61
66
|
`make check`, `npm run verify`, or a CI job, the config's `commands`
|