opencode-dev-framework 0.5.0 → 1.0.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 +34 -6
- package/dist/commands.d.ts +23 -7
- package/dist/commands.js +20 -7
- package/dist/config.d.ts +11 -0
- package/dist/config.js +64 -0
- package/dist/detect.js +1 -1
- package/dist/format-status.d.ts +8 -0
- package/dist/format-status.js +32 -2
- package/dist/gate.d.ts +1 -1
- package/dist/gate.js +13 -0
- package/dist/goal.d.ts +99 -0
- package/dist/goal.js +175 -0
- package/dist/harness.d.ts +40 -1
- package/dist/harness.js +74 -12
- package/dist/index.d.ts +2 -0
- package/dist/index.js +62 -2
- package/dist/lint.d.ts +5 -3
- package/dist/lint.js +8 -5
- package/dist/runtime-status.d.ts +29 -0
- package/dist/runtime-status.js +75 -0
- package/dist/types.d.ts +18 -0
- package/package.json +1 -1
- package/rules/10-quality-bar.md +6 -0
- package/rules/30-testing-discipline.md +6 -1
- package/rules/40-delegation.md +8 -1
- package/tui.tsx +32 -4
package/README.md
CHANGED
|
@@ -48,7 +48,8 @@ reimplemented as an OpenCode-native plugin.
|
|
|
48
48
|
- **Slash commands.** The plugin registers four TUI commands that open instant
|
|
49
49
|
modal dialogs and never feed anything to the LLM: `/df-status`, `/df-help`,
|
|
50
50
|
`/df-profile` (bare for a picker, or with an argument), and `/df-verify`
|
|
51
|
-
(runs the gate manually).
|
|
51
|
+
(runs the gate manually). `/df-goal <objective>` is a server-side command
|
|
52
|
+
instead: it starts a verified native goal (see *Slash commands* below). The `dev_framework_*` custom *tools* above remain
|
|
52
53
|
available for in-agent use.
|
|
53
54
|
|
|
54
55
|
## Profiles
|
|
@@ -167,7 +168,7 @@ commands:
|
|
|
167
168
|
typecheck: "go build ./..."
|
|
168
169
|
test: "go test ./..."
|
|
169
170
|
lint:
|
|
170
|
-
".go": "golangci-lint run {
|
|
171
|
+
".go": "golangci-lint run {dir}"
|
|
171
172
|
|
|
172
173
|
protect:
|
|
173
174
|
- ".env*"
|
|
@@ -212,12 +213,16 @@ complete example.
|
|
|
212
213
|
|
|
213
214
|
## Slash commands
|
|
214
215
|
|
|
215
|
-
|
|
216
|
+
Five slash commands are **TUI commands** registered by the bundled `./tui`
|
|
216
217
|
companion module (see *Local development* above for the `tui.json` requirement).
|
|
217
218
|
They open instantly and **never** feed text back to the LLM:
|
|
218
219
|
|
|
219
220
|
- `/df-status` — shows the current profile, guardrails, completion gate, and
|
|
220
221
|
configured commands in a modal dialog.
|
|
222
|
+
- `/df-runtime` — shows the plugin version and live hook/gate runtime state
|
|
223
|
+
(which idle-hook method the core accepted, dispatch history) in a modal
|
|
224
|
+
dialog. Read from a snapshot the server writes per project; reports
|
|
225
|
+
"not reported yet" before the first session instead of guessing.
|
|
221
226
|
- `/df-help` — lists the available dev-framework commands in a modal dialog.
|
|
222
227
|
- `/df-profile` — opens a profile picker (off / advisory / standard / strict) in
|
|
223
228
|
a modal dialog; selecting one switches the active profile immediately (written
|
|
@@ -232,6 +237,26 @@ config; the commands themselves are provided by the plugin. The
|
|
|
232
237
|
available for in-agent use (e.g. when the model wants to change the profile
|
|
233
238
|
itself).
|
|
234
239
|
|
|
240
|
+
`/df-goal <objective>` is a **server-side command** instead (registered by the
|
|
241
|
+
server plugin, not the TUI): it starts a **verified** native goal. The plugin
|
|
242
|
+
appends a short verification contract to your objective verbatim and delegates
|
|
243
|
+
exactly once to native `/goal`, which keeps owning state, review,
|
|
244
|
+
pause/resume/clear, and continuations. Requires all three: native `/goal` on
|
|
245
|
+
the core, a blocking profile (`standard`/`strict`, i.e.
|
|
246
|
+
`gate.block_on_failure: true`), and at least one configured completion check
|
|
247
|
+
(typecheck/test command, changed-file lint, `gate.acceptance`, or
|
|
248
|
+
`gate.require_review`). Otherwise it fails with an actionable error instead of
|
|
249
|
+
starting an unverified goal — use native `/goal` directly for purely semantic
|
|
250
|
+
objectives. The objective plus addendum must fit native `/goal`'s 4,000-character
|
|
251
|
+
limit; overflow is rejected, never truncated.
|
|
252
|
+
|
|
253
|
+
The agent must run `dev_framework_verify` after its final changes; the native
|
|
254
|
+
reviewer weighs that tool result as evidence and the framework idle gate stays
|
|
255
|
+
an independent backstop. This is layered verification, not a hard lock:
|
|
256
|
+
native `/goal` can still mark complete while the gate fails (or keep going
|
|
257
|
+
after it passes), both tenants can admit a continuation at one idle boundary,
|
|
258
|
+
and the framework stands down after `gate.max_blocks`.
|
|
259
|
+
|
|
235
260
|
## Limitations
|
|
236
261
|
|
|
237
262
|
- **Post-flight enforcement is a same-execution continuation, not a veto.**
|
|
@@ -244,16 +269,19 @@ itself).
|
|
|
244
269
|
hook only the net applies. `/df-status` shows which lever completed an
|
|
245
270
|
evaluation (`Continuation (idle): active` vs the event-subscribe fallback).
|
|
246
271
|
The user can always close the session, so treat the gate
|
|
247
|
-
as the strongest available enforcement, not an unbreakable lock. The **pre-flight**
|
|
272
|
+
as the strongest available enforcement, not an unbreakable lock. The missing piece — a pre-terminal vote hook — is proposed upstream ([`anomalyco/opencode#54487`](https://github.com/anomalyco/opencode/pull/54487), open); until it lands, the above is the enforcement story. The **pre-flight**
|
|
248
273
|
gate, by contrast, is a genuine hard block on every build: it denies edit tools in
|
|
249
274
|
`tool.execute.before`, before the edit lands.
|
|
250
275
|
- **Guardrails run inside OpenCode.** The `tool.execute.before` hook runs
|
|
251
276
|
after OpenCode's own permission system; it adds project rules on top, it
|
|
252
277
|
does not replace OpenCode permissions.
|
|
253
278
|
- **Formatting and linting are delegated.** The plugin does not reimplement
|
|
254
|
-
formatters or linters; you declare your
|
|
279
|
+
formatters or linters; you declare your linter commands in
|
|
255
280
|
`.opencode-dev-framework.yml` and the plugin runs them on edited files and
|
|
256
|
-
at the completion gate.
|
|
281
|
+
at the completion gate. Formatting is OpenCode core's job (`formatter` in
|
|
282
|
+
`opencode.json`, off by default) — the plugin's `commands.format` /
|
|
283
|
+
`on_edit.format` are accepted but ignored, deliberately not duplicated.
|
|
284
|
+
The plugin does not automatically rewrite `opencode.json`
|
|
257
285
|
formatter/permission fragments.
|
|
258
286
|
|
|
259
287
|
## Development
|
package/dist/commands.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { GateReport } from "./gate.js";
|
|
2
|
+
import { type CompletionInspection } from "./harness.js";
|
|
2
3
|
import type { RunCommand } from "./host.js";
|
|
3
4
|
import type { Profile, ResolvedConfig } from "./types.js";
|
|
4
5
|
/**
|
|
@@ -10,12 +11,27 @@ import type { Profile, ResolvedConfig } from "./types.js";
|
|
|
10
11
|
*/
|
|
11
12
|
export declare function changeProfile(directory: string, profile: Profile): Promise<string>;
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Manual verification result. `verdict` reports the raw inspection outcome:
|
|
15
|
+
* PASS only when the gate passes AND review (when required) is satisfied.
|
|
16
|
+
* Advisory profiles report raw FAIL here — the non-blocking behavior lives
|
|
17
|
+
* in the idle policy (`evaluateCompletion`), not in this verdict.
|
|
17
18
|
*/
|
|
18
|
-
export
|
|
19
|
+
export interface VerifyResult {
|
|
19
20
|
report: GateReport;
|
|
21
|
+
inspection: CompletionInspection;
|
|
22
|
+
verdict: "PASS" | "FAIL";
|
|
20
23
|
summary: string;
|
|
21
|
-
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Run manual verification for a project: the same full completion contract
|
|
27
|
+
* as the idle gate (gate commands plus review state), without any retry
|
|
28
|
+
* policy. Side-effect-free by construction: this function receives only a
|
|
29
|
+
* read-only changed-file snapshot and has no handle on the tracker, the
|
|
30
|
+
* block store, or session input. Git discovery is included so a verify with
|
|
31
|
+
* an empty tracker still sees worktree changes.
|
|
32
|
+
*
|
|
33
|
+
* When `config` is omitted the project config is loaded from disk.
|
|
34
|
+
* `changedFiles` is normally the server's live tracker snapshot (empty for
|
|
35
|
+
* TUI callers); Git-discovered files are unioned in either way.
|
|
36
|
+
*/
|
|
37
|
+
export declare function verifyGate(run: RunCommand, directory: string, config?: ResolvedConfig, changedFiles?: string[]): Promise<VerifyResult>;
|
package/dist/commands.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { loadConfig } from "./config.js";
|
|
3
|
-
import {
|
|
3
|
+
import { inspectCompletion } from "./harness.js";
|
|
4
4
|
import { setProfileInFile } from "./installer.js";
|
|
5
5
|
/**
|
|
6
6
|
* Change the project profile by editing the config file on disk. The server
|
|
@@ -15,13 +15,26 @@ export async function changeProfile(directory, profile) {
|
|
|
15
15
|
return `opencode-dev-framework profile set to "${profile}". Change applies on the next tool call / gate run.`;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Run
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* Run manual verification for a project: the same full completion contract
|
|
19
|
+
* as the idle gate (gate commands plus review state), without any retry
|
|
20
|
+
* policy. Side-effect-free by construction: this function receives only a
|
|
21
|
+
* read-only changed-file snapshot and has no handle on the tracker, the
|
|
22
|
+
* block store, or session input. Git discovery is included so a verify with
|
|
23
|
+
* an empty tracker still sees worktree changes.
|
|
24
|
+
*
|
|
25
|
+
* When `config` is omitted the project config is loaded from disk.
|
|
26
|
+
* `changedFiles` is normally the server's live tracker snapshot (empty for
|
|
27
|
+
* TUI callers); Git-discovered files are unioned in either way.
|
|
22
28
|
*/
|
|
23
29
|
export async function verifyGate(run, directory, config, changedFiles = []) {
|
|
24
30
|
const cfg = config ?? loadConfig(directory);
|
|
25
|
-
const
|
|
26
|
-
|
|
31
|
+
const inspection = await inspectCompletion({
|
|
32
|
+
run,
|
|
33
|
+
config: cfg,
|
|
34
|
+
directory,
|
|
35
|
+
trackerFiles: changedFiles,
|
|
36
|
+
});
|
|
37
|
+
const verdict = inspection.ok ? "PASS" : "FAIL";
|
|
38
|
+
const summary = `DEV_FRAMEWORK_VERDICT: ${verdict}\n${inspection.summary}`;
|
|
39
|
+
return { report: inspection.report, inspection, verdict, summary };
|
|
27
40
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -24,6 +24,17 @@ export declare function mapFlatConfig(flat: Record<string, unknown>): Config;
|
|
|
24
24
|
* always override profile defaults.
|
|
25
25
|
*/
|
|
26
26
|
export declare function resolveConfig(raw: Config, configPath?: string): ResolvedConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Static "meaningful check" predicate for `/df-goal` (plan §3.3).
|
|
29
|
+
*
|
|
30
|
+
* A verified goal must imply deterministic evidence where none would exist
|
|
31
|
+
* otherwise, so `/df-goal` refuses to delegate when the resolved
|
|
32
|
+
* configuration provides no real completion check at all. A check counts
|
|
33
|
+
* only when its step would actually run in `runGate` — a `run_*` flag with
|
|
34
|
+
* no command behind it produces a skipped step, which is vacuous. Users
|
|
35
|
+
* wanting a purely semantic objective use native `/goal` directly.
|
|
36
|
+
*/
|
|
37
|
+
export declare function hasMeaningfulChecks(config: ResolvedConfig): boolean;
|
|
27
38
|
/** Clear the per-session config cache (mainly for tests). */
|
|
28
39
|
export declare function clearConfigCache(): void;
|
|
29
40
|
/**
|
package/dist/config.js
CHANGED
|
@@ -27,6 +27,35 @@ export const DEFAULT_PROTECT = [
|
|
|
27
27
|
"**/vendor/**",
|
|
28
28
|
];
|
|
29
29
|
const commandMapSchema = z.union([z.string(), z.record(z.string(), z.string())]);
|
|
30
|
+
const acceptanceCheckSchema = z.object({
|
|
31
|
+
name: z
|
|
32
|
+
.string()
|
|
33
|
+
.min(1, "acceptance check name must not be empty")
|
|
34
|
+
.refine((s) => s.trim().length > 0, "acceptance check name must not be blank"),
|
|
35
|
+
command: z.string().min(1, "acceptance check command must not be empty"),
|
|
36
|
+
timeout: z.number().positive("acceptance check timeout must be positive").optional(),
|
|
37
|
+
});
|
|
38
|
+
const acceptanceListSchema = z
|
|
39
|
+
.array(acceptanceCheckSchema)
|
|
40
|
+
.optional()
|
|
41
|
+
.superRefine((checks, ctx) => {
|
|
42
|
+
if (!checks)
|
|
43
|
+
return;
|
|
44
|
+
const seen = new Map();
|
|
45
|
+
checks.forEach((check, index) => {
|
|
46
|
+
const first = seen.get(check.name);
|
|
47
|
+
if (first !== undefined) {
|
|
48
|
+
ctx.addIssue({
|
|
49
|
+
code: "custom",
|
|
50
|
+
message: `duplicate acceptance check name "${check.name}" (first at index ${first})`,
|
|
51
|
+
path: [index, "name"],
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
seen.set(check.name, index);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
30
59
|
const configSchema = z.object({
|
|
31
60
|
profile: z.enum(["off", "advisory", "standard", "strict"]).optional(),
|
|
32
61
|
commands: z
|
|
@@ -52,6 +81,7 @@ const configSchema = z.object({
|
|
|
52
81
|
require_review: z.boolean().optional(),
|
|
53
82
|
timeout: z.number().positive().optional(),
|
|
54
83
|
max_blocks: z.number().int().positive().optional(),
|
|
84
|
+
acceptance: acceptanceListSchema,
|
|
55
85
|
})
|
|
56
86
|
.optional(),
|
|
57
87
|
preflight: z.union([z.array(z.string()), z.string()]).optional(),
|
|
@@ -294,6 +324,7 @@ export function resolveConfig(raw, configPath) {
|
|
|
294
324
|
require_review: raw.gate?.require_review ?? profile !== "off",
|
|
295
325
|
timeout: raw.gate?.timeout,
|
|
296
326
|
max_blocks: raw.gate?.max_blocks ?? 3,
|
|
327
|
+
acceptance: raw.gate?.acceptance ?? [],
|
|
297
328
|
},
|
|
298
329
|
on_edit: {
|
|
299
330
|
format: raw.on_edit?.format ?? defaults.on_edit_format,
|
|
@@ -306,6 +337,39 @@ export function resolveConfig(raw, configPath) {
|
|
|
306
337
|
preflight: raw.preflight ?? [],
|
|
307
338
|
};
|
|
308
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Static "meaningful check" predicate for `/df-goal` (plan §3.3).
|
|
342
|
+
*
|
|
343
|
+
* A verified goal must imply deterministic evidence where none would exist
|
|
344
|
+
* otherwise, so `/df-goal` refuses to delegate when the resolved
|
|
345
|
+
* configuration provides no real completion check at all. A check counts
|
|
346
|
+
* only when its step would actually run in `runGate` — a `run_*` flag with
|
|
347
|
+
* no command behind it produces a skipped step, which is vacuous. Users
|
|
348
|
+
* wanting a purely semantic objective use native `/goal` directly.
|
|
349
|
+
*/
|
|
350
|
+
export function hasMeaningfulChecks(config) {
|
|
351
|
+
const gate = config.gate;
|
|
352
|
+
if (!gate)
|
|
353
|
+
return false;
|
|
354
|
+
if (gate.require_review)
|
|
355
|
+
return true;
|
|
356
|
+
if (gate.acceptance.length > 0)
|
|
357
|
+
return true;
|
|
358
|
+
if (gate.run_typecheck && config.commands.typecheck !== undefined)
|
|
359
|
+
return true;
|
|
360
|
+
if (gate.run_tests) {
|
|
361
|
+
const template = gate.scope === "changed" ? config.commands.test_changed : config.commands.test;
|
|
362
|
+
if (template !== undefined)
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
if (gate.lint_changed) {
|
|
366
|
+
const lint = config.commands.lint;
|
|
367
|
+
if (typeof lint === "string" || (lint !== undefined && Object.keys(lint).length > 0)) {
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
309
373
|
function validateConfig(data, configPath) {
|
|
310
374
|
const result = configSchema.safeParse(data);
|
|
311
375
|
if (!result.success) {
|
package/dist/detect.js
CHANGED
|
@@ -81,7 +81,7 @@ export function detectProject(directory) {
|
|
|
81
81
|
result.commands.test = "go test ./...";
|
|
82
82
|
result.commands.typecheck = "go build ./...";
|
|
83
83
|
result.commands.format = "gofumpt -w {file}";
|
|
84
|
-
result.commands.lint = "golangci-lint run {
|
|
84
|
+
result.commands.lint = "golangci-lint run {dir}";
|
|
85
85
|
return result;
|
|
86
86
|
}
|
|
87
87
|
if (has.pyProject || has.requirements) {
|
package/dist/format-status.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HookState } from "./registry.js";
|
|
2
|
+
import type { RuntimeStatus } from "./runtime-status.js";
|
|
2
3
|
import type { ResolvedConfig } from "./types.js";
|
|
3
4
|
/**
|
|
4
5
|
* Render the config-only portion of the status summary.
|
|
@@ -18,3 +19,10 @@ export declare function renderHelp(): string;
|
|
|
18
19
|
* slash-command handler.
|
|
19
20
|
*/
|
|
20
21
|
export declare function renderStatus(config: ResolvedConfig, state?: HookState | null): string;
|
|
22
|
+
/**
|
|
23
|
+
* Render the runtime snapshot for the TUI `/df-runtime` command: plugin
|
|
24
|
+
* version, which session-hook method the core accepted, and dispatch
|
|
25
|
+
* history. A null snapshot (server hasn't reported yet) renders as such —
|
|
26
|
+
* never as a negative claim about the hook.
|
|
27
|
+
*/
|
|
28
|
+
export declare function renderRuntimeStatus(snapshot: RuntimeStatus | null): string;
|
package/dist/format-status.js
CHANGED
|
@@ -54,7 +54,7 @@ export function renderConfigStatus(config) {
|
|
|
54
54
|
}
|
|
55
55
|
lines.push("");
|
|
56
56
|
lines.push("On edit:");
|
|
57
|
-
lines.push(` format: ${config.on_edit.format}`);
|
|
57
|
+
lines.push(` format: ${config.on_edit.format} (ignored — formatting is OpenCode core's job)`);
|
|
58
58
|
lines.push(` lint: ${config.on_edit.lint}`);
|
|
59
59
|
lines.push(` precommit: ${config.precommit}`);
|
|
60
60
|
lines.push("");
|
|
@@ -90,7 +90,7 @@ export function renderConfigStatus(config) {
|
|
|
90
90
|
lines.push(config.commands.test_changed ? ` ${config.commands.test_changed}` : " (not configured)");
|
|
91
91
|
lines.push(" lint:");
|
|
92
92
|
lines.push(formatCommandMap(config.commands.lint, " "));
|
|
93
|
-
lines.push(" format:");
|
|
93
|
+
lines.push(" format: (ignored — formatting is OpenCode core's job)");
|
|
94
94
|
lines.push(formatCommandMap(config.commands.format, " "));
|
|
95
95
|
lines.push("");
|
|
96
96
|
lines.push("Constitution rules:");
|
|
@@ -110,7 +110,9 @@ export function renderHelp() {
|
|
|
110
110
|
lines.push("/df-status Show the current dev-framework state");
|
|
111
111
|
lines.push("/df-profile Change the profile to off, advisory, standard, or strict");
|
|
112
112
|
lines.push("/df-verify Run the completion gate manually");
|
|
113
|
+
lines.push("/df-goal Start a verified native goal (verification contract + native /goal)");
|
|
113
114
|
lines.push("/df-help Show this message");
|
|
115
|
+
lines.push("/df-runtime Show plugin version and live hook/gate runtime state");
|
|
114
116
|
return lines.join("\n");
|
|
115
117
|
}
|
|
116
118
|
/**
|
|
@@ -153,3 +155,31 @@ export function renderStatus(config, state) {
|
|
|
153
155
|
}
|
|
154
156
|
return lines.join("\n");
|
|
155
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Render the runtime snapshot for the TUI `/df-runtime` command: plugin
|
|
160
|
+
* version, which session-hook method the core accepted, and dispatch
|
|
161
|
+
* history. A null snapshot (server hasn't reported yet) renders as such —
|
|
162
|
+
* never as a negative claim about the hook.
|
|
163
|
+
*/
|
|
164
|
+
export function renderRuntimeStatus(snapshot) {
|
|
165
|
+
const lines = ["dev-framework runtime", ""];
|
|
166
|
+
if (snapshot === null) {
|
|
167
|
+
lines.push("No runtime snapshot reported yet — open a session in this");
|
|
168
|
+
lines.push("project so the server plugin can record hook state.");
|
|
169
|
+
return lines.join("\n");
|
|
170
|
+
}
|
|
171
|
+
lines.push(`Framework: v${snapshot.frameworkVersion} (snapshot as of ${snapshot.updatedAt})`);
|
|
172
|
+
lines.push(snapshot.idleHookVia === "none"
|
|
173
|
+
? "Idle hook: not registered — event-subscribe fallback only"
|
|
174
|
+
: `Idle hook: registered via ${snapshot.idleHookVia}`);
|
|
175
|
+
if (snapshot.continuation === "idle") {
|
|
176
|
+
lines.push("Continuation: active — gate failures continue the same execution");
|
|
177
|
+
}
|
|
178
|
+
else if (snapshot.continuation === "fallback") {
|
|
179
|
+
lines.push("Continuation: event-subscribe fallback fired for a skipped boundary");
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
lines.push("Continuation: armed — registered, not yet dispatched");
|
|
183
|
+
}
|
|
184
|
+
return lines.join("\n");
|
|
185
|
+
}
|
package/dist/gate.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface ChangedFileTracker {
|
|
|
26
26
|
*/
|
|
27
27
|
export declare function createChangedFileTracker(): ChangedFileTracker;
|
|
28
28
|
export interface GateStep {
|
|
29
|
-
/** `typecheck`, `test`, or `
|
|
29
|
+
/** `typecheck`, `test`, `lint:<file>`, or `acceptance:<name>`. */
|
|
30
30
|
name: string;
|
|
31
31
|
command?: string[];
|
|
32
32
|
skipped: boolean;
|
package/dist/gate.js
CHANGED
|
@@ -111,6 +111,19 @@ export async function runGate(run, config, changedFiles, options) {
|
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
+
// Named acceptance checks run last, sequentially, in declaration order.
|
|
115
|
+
// Like every other step, a failure is aggregated — it does not abort the
|
|
116
|
+
// remaining steps. `{files}` substitution and the project `cwd` match the
|
|
117
|
+
// test-command semantics; per-check timeout overrides the gate default.
|
|
118
|
+
for (const check of config.gate.acceptance) {
|
|
119
|
+
const command = substituteFiles(check.command, changedFiles);
|
|
120
|
+
steps.push({
|
|
121
|
+
name: `acceptance:${check.name}`,
|
|
122
|
+
command,
|
|
123
|
+
skipped: false,
|
|
124
|
+
result: await run(command, { cwd: options?.cwd, timeout: check.timeout ?? timeout }),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
114
127
|
const ran = steps.some((step) => !step.skipped);
|
|
115
128
|
const failedSteps = steps.filter((step) => !step.skipped && step.result !== undefined && isFailure(step.result));
|
|
116
129
|
return {
|
package/dist/goal.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/df-goal`: verified-goal wrapper around native `/goal`.
|
|
3
|
+
*
|
|
4
|
+
* A thin adapter, not a second goal engine: it validates that verified-goal
|
|
5
|
+
* mode is meaningful and available (§3.3), appends the framework verification
|
|
6
|
+
* addendum to the user's objective verbatim (§3.2), and delegates exactly
|
|
7
|
+
* once to native `/goal` via `session.command`. Native `/goal` keeps owning
|
|
8
|
+
* kickoff, state, reviewer, pause/resume/clear, and continuations; the
|
|
9
|
+
* framework's idle gate stays the independent deterministic backstop.
|
|
10
|
+
*
|
|
11
|
+
* All policy here is pure (input -> data, no session I/O): `src/index.ts`
|
|
12
|
+
* owns the `ctx.command.transform` registration, capability probing, and
|
|
13
|
+
* delegation call. Unit tests drive these functions with a stub delegate.
|
|
14
|
+
*/
|
|
15
|
+
import type { ResolvedConfig } from "./types.js";
|
|
16
|
+
/**
|
|
17
|
+
* Native `/goal` objective limit. Counts JS `text.length` (UTF-16 code
|
|
18
|
+
* units) — confirmed by the Phase 0 spike against core `goal.ts`
|
|
19
|
+
* (`MAX_OBJECTIVE = 4_000`), not bytes or grapheme clusters.
|
|
20
|
+
*/
|
|
21
|
+
export declare const NATIVE_GOAL_LIMIT = 4000;
|
|
22
|
+
/**
|
|
23
|
+
* Verification addendum appended to the objective (plan §3.2). The addendum
|
|
24
|
+
* length in limit accounting is computed from this exact string at
|
|
25
|
+
* delegation time, never from a hardcoded constant.
|
|
26
|
+
*/
|
|
27
|
+
export declare const VERIFICATION_ADDENDUM = "Verification contract added by opencode-dev-framework:\n\nBefore declaring this goal complete, run dev_framework_verify after your final changes. A FAIL result means the goal is incomplete: fix the underlying cause and run verification again. Any later edit invalidates an earlier verification result. PASS is required but does not replace the original objective or its acceptance criteria. Do not disable, skip, or weaken the configured checks to obtain PASS.";
|
|
28
|
+
export type GoalBuildResult = {
|
|
29
|
+
ok: true;
|
|
30
|
+
text: string;
|
|
31
|
+
alreadyWrapped: boolean;
|
|
32
|
+
} | {
|
|
33
|
+
ok: false;
|
|
34
|
+
error: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Append the verification addendum to the objective without rewriting the
|
|
38
|
+
* user's text. An objective that already contains the addendum is used
|
|
39
|
+
* verbatim (never double-wrapped on retry). The complete string counts
|
|
40
|
+
* toward the native limit; overflow is rejected with lengths, never
|
|
41
|
+
* silently truncated.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildVerifiedObjective(objective: string): GoalBuildResult;
|
|
44
|
+
export type GoalAvailability = {
|
|
45
|
+
ok: true;
|
|
46
|
+
} | {
|
|
47
|
+
ok: false;
|
|
48
|
+
error: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Availability/profile/meaningful-check rules (plan §3.3). `/df-goal` means
|
|
52
|
+
* verified goal, not an alias for `/goal`: every failure names the exact
|
|
53
|
+
* cause and points at the alternatives (enable a blocking profile or use
|
|
54
|
+
* native `/goal` directly for an unverified objective).
|
|
55
|
+
*/
|
|
56
|
+
export declare function checkGoalAvailability(config: ResolvedConfig, nativeGoalAvailable: boolean): GoalAvailability;
|
|
57
|
+
/** Single delegation call to native `/goal` (flat core protocol shape). */
|
|
58
|
+
export type GoalDelegate = (args: {
|
|
59
|
+
sessionID: string;
|
|
60
|
+
name: string;
|
|
61
|
+
text: string;
|
|
62
|
+
}) => Promise<unknown>;
|
|
63
|
+
export interface RunGoalDeps {
|
|
64
|
+
config: ResolvedConfig;
|
|
65
|
+
/** Raw objective text from the command invocation. */
|
|
66
|
+
objective: string;
|
|
67
|
+
sessionID: string;
|
|
68
|
+
nativeGoalAvailable: boolean;
|
|
69
|
+
delegate: GoalDelegate;
|
|
70
|
+
}
|
|
71
|
+
export type RunGoalResult = {
|
|
72
|
+
delegated: true;
|
|
73
|
+
text: string;
|
|
74
|
+
alreadyWrapped: boolean;
|
|
75
|
+
} | {
|
|
76
|
+
delegated: false;
|
|
77
|
+
error: string;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Validate, wrap, and delegate exactly once. Native delegation errors
|
|
81
|
+
* propagate untouched — never an unverified fallback. The wrapper itself
|
|
82
|
+
* admits no kickoff synthetic message.
|
|
83
|
+
*/
|
|
84
|
+
export declare function runGoalCommand(deps: RunGoalDeps): Promise<RunGoalResult>;
|
|
85
|
+
/**
|
|
86
|
+
* Extract the raw objective from a command invocation prompt. The
|
|
87
|
+
* invocation prompt is a `Prompt` struct (`{ text, ... }`); accept a bare
|
|
88
|
+
* string defensively and fall back to empty (rejected downstream as an
|
|
89
|
+
* empty objective) for anything else.
|
|
90
|
+
*/
|
|
91
|
+
export declare function extractObjectiveText(prompt: unknown): string;
|
|
92
|
+
/**
|
|
93
|
+
* Capability probe over `command.list()` output: true when an entry named
|
|
94
|
+
* `goal` is present. The real output shape is `{ location, data: [...] }`
|
|
95
|
+
* (`CommandListOutput`); a bare array is tolerated for forward
|
|
96
|
+
* compatibility. Defensive throughout (SDK codegen drifts; core is truth) —
|
|
97
|
+
* anything unrecognized means unavailable, never an assumed capability.
|
|
98
|
+
*/
|
|
99
|
+
export declare function isNativeGoalListed(listed: unknown): boolean;
|