opencode-dev-framework 1.11.1 → 1.13.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 +10 -5
- package/dist/adapters/dsh/extract.js +2 -2
- package/dist/adapters/dsh/index.d.ts +71 -0
- package/dist/adapters/dsh/index.js +232 -11
- package/dist/adapters/opencode/index.js +78 -4
- package/dist/core/commands.d.ts +36 -1
- package/dist/core/commands.js +122 -2
- package/dist/core/config.js +9 -3
- package/dist/core/format-status.js +1 -0
- package/dist/core/harness.d.ts +26 -0
- package/dist/core/harness.js +48 -2
- package/dist/core/install-dsh.js +1 -1
- package/dist/core/installer.d.ts +12 -0
- package/dist/core/installer.js +141 -0
- package/dist/core/logger.d.ts +3 -21
- package/dist/core/logger.js +3 -24
- package/dist/core/run-hooks.d.ts +7 -0
- package/dist/core/run-hooks.js +1 -0
- package/dist/core/types.d.ts +8 -0
- 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
|
@@ -36,7 +36,7 @@ Five minutes from zero to your first gated session.
|
|
|
36
36
|
|
|
37
37
|
**On OpenCode:**
|
|
38
38
|
|
|
39
|
-
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.
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
opencode plugin add opencode-dev-framework
|
|
@@ -125,7 +125,7 @@ differ. Neither harness is the "real" one; each is stronger somewhere:
|
|
|
125
125
|
| Redirect targets (`a > file`) | Not guard-checked | **Guard-checked** (wider than OpenCode) |
|
|
126
126
|
| denial identity | Reason text | Reason text + structured `{name, code}` |
|
|
127
127
|
| Skills | `.opencode/skills` (native) | `.dsh/skills` (installed by `df-init`, kept current by `df-update`) |
|
|
128
|
-
| 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 |
|
|
129
129
|
| Goals | `/df-goal` wraps native `/goal` | `df-goal` creates the host goal with the same verification contract |
|
|
130
130
|
| Install | One command (`opencode plugin add`) | `dsh plugin add` + `df install-dsh` (bundle auto-wires the base entry) |
|
|
131
131
|
| Review UI | Instant TUI modals, never feed the LLM | Host commands returning text |
|
|
@@ -162,7 +162,8 @@ semantics, block budgeting, `protect_off` scope, and all eight
|
|
|
162
162
|
synthetic continuation, bounded by `gate.max_blocks` (fewer when
|
|
163
163
|
the failure repeats with no new edits — the gate stands down early on
|
|
164
164
|
zero progress). On DSH the same verdict runs pre-terminal in the same
|
|
165
|
-
turn — no re-prompt round-trip.
|
|
165
|
+
turn — no re-prompt round-trip. Scratch and generated files can skip
|
|
166
|
+
evaluation via `gate.ignore` or `/df-ignore`.
|
|
166
167
|
- **Verified goals (`/df-goal`).** Wraps a task in native `/goal` with a
|
|
167
168
|
verification contract the reviewer weighs as evidence.
|
|
168
169
|
- **Pre-flight gate (optional).** Denies edits until the agent records
|
|
@@ -267,13 +268,14 @@ How each layer is enforced, and what it honestly cannot do:
|
|
|
267
268
|
| `/df-help` | Instant modal: lists the dev-framework commands. |
|
|
268
269
|
| `/df-profile` | Instant modal picker (or `/df-profile <name>`): switches profile now, written to config. |
|
|
269
270
|
| `/df-verify` | Runs the verification suite manually; pass/fail summary in a modal. |
|
|
271
|
+
| `/df-ignore` | Server-side command: skips globs for this session (`-s` stores to `gate.ignore`, `-l` lists, `-r` removes). |
|
|
270
272
|
| `/df-init` | Server-side command: scaffolds templates, writes the detected config, trial-runs it, hands the brief to the agent. |
|
|
271
273
|
| `/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. |
|
|
272
274
|
| `/df-goal <objective>` | Server-side command: starts a **verified** native goal (requires native `/goal`, a blocking profile, and at least one real check). |
|
|
273
275
|
|
|
274
276
|
The TUI commands open instantly and never feed the LLM; `/df-init`,
|
|
275
277
|
`/df-update`, and `/df-goal` are server-side and drive the session. Same
|
|
276
|
-
|
|
278
|
+
nine names on DSH, where they run as host commands returning text instead
|
|
277
279
|
of modals. Full reference:
|
|
278
280
|
[`docs/user/commands.md`](docs/user/commands.md).
|
|
279
281
|
|
|
@@ -290,7 +292,10 @@ of modals. Full reference:
|
|
|
290
292
|
always re-verifies the final tree from scratch.
|
|
291
293
|
- Formatting and linting use your project tooling — the framework never
|
|
292
294
|
reimplements them. On OpenCode the host runs the formatter; on DSH the
|
|
293
|
-
adapter runs your configured formatter command before linting.
|
|
295
|
+
adapter runs your configured formatter command before linting. Want
|
|
296
|
+
formatting on OpenCode? Configure the host `formatter` in
|
|
297
|
+
`opencode.json` ([docs](https://opencode.ai/docs/formatters/)) — the
|
|
298
|
+
plugin defers to it and never runs its own.
|
|
294
299
|
|
|
295
300
|
### OpenCode
|
|
296
301
|
|
|
@@ -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
|
|
@@ -20,7 +20,7 @@ import { randomUUID } from "node:crypto";
|
|
|
20
20
|
import { readFile, stat } from "node:fs/promises";
|
|
21
21
|
import { join } from "node:path";
|
|
22
22
|
import { createBlockStore, createStuckSnapshotStore } from "../../core/block-store.js";
|
|
23
|
-
import { changeProfile, verifyGate } from "../../core/commands.js";
|
|
23
|
+
import { changeProfile, dfIgnore, parseIgnoreArgs, verifyGate, } from "../../core/commands.js";
|
|
24
24
|
import { CONFIG_FILE_PRECEDENCE, clearConfigCache, loadConfig } from "../../core/config.js";
|
|
25
25
|
import { renderHelp, renderRuntimeStatus, renderStatus } from "../../core/format-status.js";
|
|
26
26
|
import { createChangedFileTracker } from "../../core/gate.js";
|
|
@@ -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 " +
|
|
@@ -571,6 +668,7 @@ export function apply(ctx) {
|
|
|
571
668
|
stuckSnapshots: createStuckSnapshotStore(undefined),
|
|
572
669
|
lintLimiter: createLintLimiter(),
|
|
573
670
|
passCache: createPassCache(),
|
|
671
|
+
sessionIgnores: [],
|
|
574
672
|
lastConfigCheck: 0,
|
|
575
673
|
lastIdleHandled: new Map(),
|
|
576
674
|
// Probed once at mount so `df-status` reads degraded mounts as
|
|
@@ -694,6 +792,18 @@ export function apply(ctx) {
|
|
|
694
792
|
if (typeof subagents?.startActivation !== "function") {
|
|
695
793
|
return null;
|
|
696
794
|
}
|
|
795
|
+
// Capability probe (plan 27): `outputSchema` is per-provider — the
|
|
796
|
+
// host rejects a start that needs an unsupported capability, so probe
|
|
797
|
+
// the exact provider this start will use and degrade to the
|
|
798
|
+
// closing-text path on any doubt (absent seam, unknown provider,
|
|
799
|
+
// throwing probe). Never throws out of dispatch.
|
|
800
|
+
let structuredCapable = false;
|
|
801
|
+
try {
|
|
802
|
+
structuredCapable = subagents.getProvider("spawn")?.capabilities?.outputSchema === true;
|
|
803
|
+
}
|
|
804
|
+
catch {
|
|
805
|
+
structuredCapable = false;
|
|
806
|
+
}
|
|
697
807
|
try {
|
|
698
808
|
specialistCounter += 1;
|
|
699
809
|
const name = `${SPECIALIST_NAME_STEMS[kind]}-${specialistCounter}`;
|
|
@@ -701,7 +811,11 @@ export function apply(ctx) {
|
|
|
701
811
|
const prompt = `${brief}\n\nYou are investigating, not implementing: report findings ` +
|
|
702
812
|
`as text, do not edit anything.\nChanged files under review:\n` +
|
|
703
813
|
`${changedFiles.map((file) => `- ${file}`).join("\n")}\n\n` +
|
|
704
|
-
`Gate summary for this block:\n${gateSummary}
|
|
814
|
+
`Gate summary for this block:\n${gateSummary}` +
|
|
815
|
+
(structuredCapable
|
|
816
|
+
? `\n\nAlso report each finding with the structured-output tool ` +
|
|
817
|
+
`(one entry per finding), then close with a short text summary as usual.`
|
|
818
|
+
: "");
|
|
705
819
|
const activation = await subagents.startActivation({
|
|
706
820
|
provider: "spawn",
|
|
707
821
|
label: `odf specialist review (${kind})`,
|
|
@@ -709,11 +823,12 @@ export function apply(ctx) {
|
|
|
709
823
|
prompt: [{ type: "text", text: prompt }],
|
|
710
824
|
parent: agent,
|
|
711
825
|
...(reviewerPresetReady ? { agentPreset: REVIEWER_PRESET_ID } : {}),
|
|
826
|
+
...(structuredCapable ? { outputSchema: SPECIALIST_FINDINGS_SCHEMA } : {}),
|
|
712
827
|
...(signal !== undefined ? { signal } : {}),
|
|
713
828
|
delivery: "parent",
|
|
714
829
|
});
|
|
715
830
|
trackSpecialist(sessionKey, kind, activation.name);
|
|
716
|
-
await safeLog(state, "info", `specialist dispatched: ${activation.name}`, {
|
|
831
|
+
await safeLog(state, "info", `specialist dispatched: ${activation.name} (${structuredCapable ? "structured" : "text"} findings)`, {
|
|
717
832
|
sessionID: sessionKey,
|
|
718
833
|
});
|
|
719
834
|
return activation.name;
|
|
@@ -734,7 +849,7 @@ export function apply(ctx) {
|
|
|
734
849
|
}
|
|
735
850
|
const paths = extractDshPaths(exec);
|
|
736
851
|
const rawInput = typeof exec.arguments === "object" && exec.arguments !== null
|
|
737
|
-
? exec.arguments
|
|
852
|
+
? exec.arguments.input
|
|
738
853
|
: undefined;
|
|
739
854
|
warnApplyPatchSkip(state, exec, rawInput, paths);
|
|
740
855
|
// Children never write the parent's review artifact. Not a
|
|
@@ -870,7 +985,7 @@ export function apply(ctx) {
|
|
|
870
985
|
}
|
|
871
986
|
const execArgs = exec.arguments;
|
|
872
987
|
const rawInput = typeof execArgs === "object" && execArgs !== null
|
|
873
|
-
? execArgs
|
|
988
|
+
? execArgs.input
|
|
874
989
|
: undefined;
|
|
875
990
|
warnApplyPatchSkip(state, exec, rawInput, paths);
|
|
876
991
|
if (state.config.precommit === "auto" && state.precommitAvailable === undefined) {
|
|
@@ -1015,11 +1130,18 @@ export function apply(ctx) {
|
|
|
1015
1130
|
}
|
|
1016
1131
|
}
|
|
1017
1132
|
const finding = (match[2] ?? "").trim();
|
|
1018
|
-
|
|
1133
|
+
// Structured first (plan 27): when the child satisfied its
|
|
1134
|
+
// output schema, the notice carries a `Structured result:`
|
|
1135
|
+
// block — exact submitted JSON beats the quoted closing prose.
|
|
1136
|
+
// Null (absent/malformed/empty) falls back to the closing
|
|
1137
|
+
// text, preserving the pre-structured behavior verbatim.
|
|
1138
|
+
const structuredLines = extractStructuredFindings(text);
|
|
1139
|
+
const folded = structuredLines ?? (finding !== "" ? [finding] : []);
|
|
1140
|
+
if (folded.length > 0) {
|
|
1019
1141
|
const collected = specialistFindings.get(key) ?? [];
|
|
1020
|
-
collected.push(`[${finished}] ${
|
|
1142
|
+
collected.push(`[${finished}] ${structuredLines !== null ? "(structured) " : ""}${folded.join("\n")}`);
|
|
1021
1143
|
specialistFindings.set(key, collected);
|
|
1022
|
-
await safeLog(state, "info", `specialist findings collected: ${finished}`, {
|
|
1144
|
+
await safeLog(state, "info", `specialist findings collected: ${finished} (${structuredLines !== null ? "structured" : "text"})`, {
|
|
1023
1145
|
sessionID: key,
|
|
1024
1146
|
});
|
|
1025
1147
|
}
|
|
@@ -1298,6 +1420,37 @@ export function apply(ctx) {
|
|
|
1298
1420
|
}
|
|
1299
1421
|
},
|
|
1300
1422
|
});
|
|
1423
|
+
// Ignore hotlist: session-scoped gate skips with an explicit path to
|
|
1424
|
+
// permanence. Bare patterns add for this session; -s stores to
|
|
1425
|
+
// gate.ignore; -l lists both sources; -r drops session patterns.
|
|
1426
|
+
ctx.commands.register({
|
|
1427
|
+
name: "df-ignore",
|
|
1428
|
+
description: "Add glob patterns to the completion-gate ignore hotlist (session-scoped; -s stores to gate.ignore, -l lists, -r removes).",
|
|
1429
|
+
input: {
|
|
1430
|
+
hint: "[patterns] [-s|--store] [-l|--list] [-r|--remove ...] (removals are session-only)",
|
|
1431
|
+
},
|
|
1432
|
+
handler: async (invocation) => {
|
|
1433
|
+
try {
|
|
1434
|
+
await reloadConfigIfChanged(state);
|
|
1435
|
+
let parsed;
|
|
1436
|
+
try {
|
|
1437
|
+
parsed = parseIgnoreArgs(invocation.rawInput);
|
|
1438
|
+
}
|
|
1439
|
+
catch (error) {
|
|
1440
|
+
return { kind: "error", text: error.message };
|
|
1441
|
+
}
|
|
1442
|
+
const result = await dfIgnore(state.directory, state.sessionIgnores, state.config, parsed);
|
|
1443
|
+
if (parsed.store) {
|
|
1444
|
+
clearConfigCache();
|
|
1445
|
+
state.config = loadConfig(state.directory);
|
|
1446
|
+
}
|
|
1447
|
+
return { kind: "success", text: result.message };
|
|
1448
|
+
}
|
|
1449
|
+
catch (error) {
|
|
1450
|
+
return { kind: "error", text: `df-ignore failed: ${error?.message ?? error}` };
|
|
1451
|
+
}
|
|
1452
|
+
},
|
|
1453
|
+
});
|
|
1301
1454
|
// On-demand gate: same full completion contract as the turn-stopping gate,
|
|
1302
1455
|
// run when asked instead of at the boundary. Fills the slot the missing
|
|
1303
1456
|
// TUI `/df-verify` leaves on DSH.
|
|
@@ -1307,7 +1460,7 @@ export function apply(ctx) {
|
|
|
1307
1460
|
handler: async () => {
|
|
1308
1461
|
try {
|
|
1309
1462
|
await reloadConfigIfChanged(state);
|
|
1310
|
-
const result = await verifyGate(run, state.directory, state.config, state.tracker.getChangedFiles());
|
|
1463
|
+
const result = await verifyGate(run, state.directory, state.config, state.tracker.getChangedFiles(), state.sessionIgnores);
|
|
1311
1464
|
return { kind: "success", text: result.summary };
|
|
1312
1465
|
}
|
|
1313
1466
|
catch (error) {
|
|
@@ -1486,7 +1639,7 @@ export function apply(ctx) {
|
|
|
1486
1639
|
// verify scopes `changed` steps to real edits (mirror of opencode).
|
|
1487
1640
|
const cfg = holder?.config ?? loadConfig(targetDir);
|
|
1488
1641
|
const changed = holder !== null ? holder.tracker.getChangedFiles() : [];
|
|
1489
|
-
const { summary } = await verifyGate(run, targetDir, cfg, changed);
|
|
1642
|
+
const { summary } = await verifyGate(run, targetDir, cfg, changed, holder?.sessionIgnores ?? []);
|
|
1490
1643
|
return summary;
|
|
1491
1644
|
},
|
|
1492
1645
|
});
|
|
@@ -1532,6 +1685,74 @@ export function apply(ctx) {
|
|
|
1532
1685
|
return `${message} Change applied immediately.`;
|
|
1533
1686
|
},
|
|
1534
1687
|
});
|
|
1688
|
+
registerDshTool(ctx, state, {
|
|
1689
|
+
name: "dev_framework_ignore",
|
|
1690
|
+
description: "Add glob patterns to the completion-gate ignore hotlist (session-scoped; store:true persists to gate.ignore, list:true shows both sources, remove:[...] drops session patterns only, never stored config).",
|
|
1691
|
+
parameters: {
|
|
1692
|
+
type: "object",
|
|
1693
|
+
properties: {
|
|
1694
|
+
patterns: {
|
|
1695
|
+
type: "array",
|
|
1696
|
+
items: { type: "string" },
|
|
1697
|
+
description: "Glob patterns to ignore (e.g. ['scratch/**', '*.local'])",
|
|
1698
|
+
},
|
|
1699
|
+
store: {
|
|
1700
|
+
type: "boolean",
|
|
1701
|
+
description: "Persist to gate.ignore in the config file (default false: session only)",
|
|
1702
|
+
},
|
|
1703
|
+
list: {
|
|
1704
|
+
type: "boolean",
|
|
1705
|
+
description: "List session and stored patterns instead of changing anything",
|
|
1706
|
+
},
|
|
1707
|
+
remove: {
|
|
1708
|
+
type: "array",
|
|
1709
|
+
items: { type: "string" },
|
|
1710
|
+
description: "Session patterns to drop",
|
|
1711
|
+
},
|
|
1712
|
+
directory: {
|
|
1713
|
+
type: "string",
|
|
1714
|
+
description: "Project directory (defaults to current project)",
|
|
1715
|
+
},
|
|
1716
|
+
},
|
|
1717
|
+
additionalProperties: false,
|
|
1718
|
+
},
|
|
1719
|
+
execute: async (input) => {
|
|
1720
|
+
const args = input;
|
|
1721
|
+
const targetDir = args.directory ?? state.directory;
|
|
1722
|
+
const liveState = getActiveState();
|
|
1723
|
+
const live = liveState !== null && liveState.directory === targetDir ? liveState : null;
|
|
1724
|
+
const own = state.directory === targetDir ? state : null;
|
|
1725
|
+
const holder = live ?? own;
|
|
1726
|
+
const parsed = {
|
|
1727
|
+
patterns: args.patterns ?? [],
|
|
1728
|
+
store: args.store ?? false,
|
|
1729
|
+
list: args.list ?? false,
|
|
1730
|
+
remove: args.remove ?? [],
|
|
1731
|
+
};
|
|
1732
|
+
if (holder === null && parsed.patterns.length > 0 && !parsed.store) {
|
|
1733
|
+
return (`No live session for ${targetDir}: session ignores have nowhere to live. ` +
|
|
1734
|
+
`Re-run with store:true to persist to gate.ignore instead.`);
|
|
1735
|
+
}
|
|
1736
|
+
const sessionIgnores = holder?.sessionIgnores ?? [];
|
|
1737
|
+
const cfg = holder?.config ?? loadConfig(targetDir);
|
|
1738
|
+
const result = await dfIgnore(targetDir, sessionIgnores, cfg, parsed);
|
|
1739
|
+
if (parsed.store) {
|
|
1740
|
+
clearConfigCache();
|
|
1741
|
+
const newConfig = loadConfig(targetDir);
|
|
1742
|
+
if (state.directory === targetDir) {
|
|
1743
|
+
state.config = newConfig;
|
|
1744
|
+
}
|
|
1745
|
+
if (live !== null && live !== state) {
|
|
1746
|
+
live.config = newConfig;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
let message = result.message;
|
|
1750
|
+
if (holder === null && result.added.length > 0) {
|
|
1751
|
+
message += ` (No live session for ${targetDir}: kept in config only.)`;
|
|
1752
|
+
}
|
|
1753
|
+
return message;
|
|
1754
|
+
},
|
|
1755
|
+
});
|
|
1535
1756
|
registerDshTool(ctx, state, {
|
|
1536
1757
|
name: "dev_framework_status",
|
|
1537
1758
|
description: "Show the current opencode-dev-framework state for the project: active profile, guardrails, completion gate, on-edit behavior, tracked changed files, and block counts.",
|
|
@@ -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);
|
|
@@ -164,6 +163,7 @@ const plugin = Plugin.define({
|
|
|
164
163
|
configMtime,
|
|
165
164
|
lintLimiter: createLintLimiter(),
|
|
166
165
|
passCache: createPassCache(),
|
|
166
|
+
sessionIgnores: [],
|
|
167
167
|
lastConfigCheck: 0,
|
|
168
168
|
lastIdleHandled: new Map(),
|
|
169
169
|
};
|
|
@@ -196,7 +196,7 @@ const plugin = Plugin.define({
|
|
|
196
196
|
// the stale hook must NOT double-enforce), and (c) teardown racing
|
|
197
197
|
// an in-flight handler between awaits (captured `state` stays valid
|
|
198
198
|
// while the global may be cleared). See issue #1 follow-up.
|
|
199
|
-
// 1) Constitution injection — per model request (
|
|
199
|
+
// 1) Constitution injection — per model request (session.hook("context", ...))
|
|
200
200
|
trackRegistration(await ctx.session.hook("context", async (event) => {
|
|
201
201
|
if (getActiveState() !== state)
|
|
202
202
|
return;
|
|
@@ -501,7 +501,7 @@ const plugin = Plugin.define({
|
|
|
501
501
|
catch {
|
|
502
502
|
await safeLog(state, "warn", "could not register permission.evaluate hook; guardrails use execute.before only");
|
|
503
503
|
}
|
|
504
|
-
// 2) Guardrails — tool execution blocking (
|
|
504
|
+
// 2) Guardrails — tool execution blocking (ctx.tool.hook("execute.before", ...))
|
|
505
505
|
// Stale-hook fail-open: the closure captures its own `state` and allows
|
|
506
506
|
// the call whenever it is no longer live — torn down (activeState null)
|
|
507
507
|
// or superseded by a newer setup (activeState is a different instance,
|
|
@@ -686,6 +686,80 @@ const plugin = Plugin.define({
|
|
|
686
686
|
return { content: `${message} Change applied immediately.` };
|
|
687
687
|
},
|
|
688
688
|
});
|
|
689
|
+
editor.add({
|
|
690
|
+
name: "dev_framework_ignore",
|
|
691
|
+
description: "Add glob patterns to the completion-gate ignore hotlist (e.g. scratch notes, generated output) so the gate skips them. Session-scoped by default; pass store:true to persist to gate.ignore in the config file. Use list:true to show session and stored patterns, or remove:[...] to drop session patterns (removals never touch stored config).",
|
|
692
|
+
input: {
|
|
693
|
+
type: "object",
|
|
694
|
+
properties: {
|
|
695
|
+
patterns: {
|
|
696
|
+
type: "array",
|
|
697
|
+
items: { type: "string" },
|
|
698
|
+
description: "Glob patterns to ignore (e.g. ['scratch/**', '*.local'])",
|
|
699
|
+
},
|
|
700
|
+
store: {
|
|
701
|
+
type: "boolean",
|
|
702
|
+
description: "Persist to gate.ignore in the config file (default false: session only)",
|
|
703
|
+
},
|
|
704
|
+
list: {
|
|
705
|
+
type: "boolean",
|
|
706
|
+
description: "List session and stored patterns instead of changing anything",
|
|
707
|
+
},
|
|
708
|
+
remove: {
|
|
709
|
+
type: "array",
|
|
710
|
+
items: { type: "string" },
|
|
711
|
+
description: "Session patterns to drop",
|
|
712
|
+
},
|
|
713
|
+
directory: {
|
|
714
|
+
type: "string",
|
|
715
|
+
description: "Project directory (defaults to current project)",
|
|
716
|
+
},
|
|
717
|
+
},
|
|
718
|
+
additionalProperties: false,
|
|
719
|
+
},
|
|
720
|
+
async execute(input) {
|
|
721
|
+
const { dfIgnore } = await import("../../core/commands.js");
|
|
722
|
+
const { clearConfigCache: ccc, loadConfig: lc } = await import("../../core/config.js");
|
|
723
|
+
const { loadConstitution: lc2 } = await import("../../core/rules.js");
|
|
724
|
+
const args = input;
|
|
725
|
+
const targetDir = args.directory ?? directory;
|
|
726
|
+
const liveState = getActiveState();
|
|
727
|
+
const live = liveState && liveState.directory === targetDir ? liveState : null;
|
|
728
|
+
const own = state.directory === targetDir ? state : null;
|
|
729
|
+
const holder = live ?? own;
|
|
730
|
+
if (holder === null && (args.patterns?.length ?? 0) > 0 && !args.store) {
|
|
731
|
+
return {
|
|
732
|
+
content: `No live session for ${targetDir}: session ignores have nowhere to live. Re-run with store:true to persist to gate.ignore instead.`,
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
const sessionIgnores = holder?.sessionIgnores ?? [];
|
|
736
|
+
const cfg = holder?.config ?? lc(targetDir);
|
|
737
|
+
const result = await dfIgnore(targetDir, sessionIgnores, cfg, {
|
|
738
|
+
patterns: args.patterns ?? [],
|
|
739
|
+
store: args.store ?? false,
|
|
740
|
+
list: args.list ?? false,
|
|
741
|
+
remove: args.remove ?? [],
|
|
742
|
+
});
|
|
743
|
+
if (args.store) {
|
|
744
|
+
ccc();
|
|
745
|
+
const newConfig = lc(targetDir);
|
|
746
|
+
const { constitution: newConstitution } = await lc2(newConfig, targetDir);
|
|
747
|
+
if (state.directory === targetDir) {
|
|
748
|
+
state.config = newConfig;
|
|
749
|
+
state.constitution = newConstitution;
|
|
750
|
+
}
|
|
751
|
+
if (live && live !== state && live.directory === targetDir) {
|
|
752
|
+
live.config = newConfig;
|
|
753
|
+
live.constitution = newConstitution;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
let content = result.message;
|
|
757
|
+
if (holder === null && result.added.length > 0) {
|
|
758
|
+
content += ` (No live session for ${targetDir}: kept in config only.)`;
|
|
759
|
+
}
|
|
760
|
+
return { content };
|
|
761
|
+
},
|
|
762
|
+
});
|
|
689
763
|
editor.add({
|
|
690
764
|
name: "dev_framework_verify",
|
|
691
765
|
description: "Run the full opencode-dev-framework completion contract now (typecheck, tests, changed-file lint, peer-review state) and return the summary. The first line is DEV_FRAMEWORK_VERDICT: PASS or FAIL, reporting the raw inspection outcome. Use for a mid-session gate check without waiting for session idle; unlike the idle gate this never re-prompts, it only reports, and it never mutates retry state.",
|
|
@@ -711,7 +785,7 @@ const plugin = Plugin.define({
|
|
|
711
785
|
// mid-session verify scopes `changed` steps to real edits.
|
|
712
786
|
const cfg = holder?.config ?? loadConfig(targetDir);
|
|
713
787
|
const changed = holder ? holder.tracker.getChangedFiles() : [];
|
|
714
|
-
const { summary } = await verifyGate(state.run, targetDir, cfg, changed);
|
|
788
|
+
const { summary } = await verifyGate(state.run, targetDir, cfg, changed, holder?.sessionIgnores ?? []);
|
|
715
789
|
return { content: summary };
|
|
716
790
|
},
|
|
717
791
|
});
|