opencode-dev-framework 0.1.14 → 0.1.18
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 +24 -14
- package/bin/df +4 -3
- package/dist/command-utils.d.ts +12 -0
- package/dist/command-utils.js +46 -0
- package/dist/format-status.d.ts +9 -0
- package/dist/format-status.js +109 -0
- package/dist/gate.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +138 -14
- package/dist/installer.js +1 -1
- package/dist/lint.js +1 -1
- package/dist/logger.d.ts +4 -0
- package/dist/logger.js +21 -0
- package/dist/messenger.d.ts +9 -0
- package/dist/messenger.js +28 -0
- package/dist/protect.d.ts +2 -1
- package/dist/protect.js +48 -1
- package/dist/registry.d.ts +13 -0
- package/dist/registry.js +22 -2
- package/dist/rules.d.ts +3 -2
- package/dist/rules.js +9 -3
- package/dist/tools.js +2 -103
- package/package.json +1 -1
- package/rules/00-activation.md +10 -16
- package/rules/40-delegation.md +6 -4
- package/dist/config-to-opencode.d.ts +0 -51
- package/dist/config-to-opencode.js +0 -124
- package/templates/.opencode/commands/df-profile.md +0 -7
- package/templates/.opencode/commands/df-status.md +0 -8
- package/templates/.opencode/commands/df-verify.md +0 -8
package/README.md
CHANGED
|
@@ -24,16 +24,18 @@ reimplemented as an OpenCode-native plugin.
|
|
|
24
24
|
(up to `gate.max_blocks` times) so the agent must fix the failures. In older
|
|
25
25
|
versions the gate reports loudly via `session.idle`.
|
|
26
26
|
- **Custom tools.** `dev_framework_init` scaffolds project-level agents,
|
|
27
|
-
skills,
|
|
27
|
+
skills, local rules directory, and config; `dev_framework_set_profile` changes the profile
|
|
28
28
|
in-session without restarting; `dev_framework_status` reports the current
|
|
29
29
|
profile, guardrails, gate, and tracked changed files.
|
|
30
30
|
- **CLI installer.** `df init` auto-detects your language and writes a config
|
|
31
31
|
with sensible commands; `df profile <name>` changes the profile from the
|
|
32
32
|
shell; `df status` / `df version` report template state and the version.
|
|
33
|
-
- **Slash
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
- **Slash commands.** `/df-status`, `/df-verify`, `/df-profile`, and `/df-help`
|
|
34
|
+
are registered directly by the plugin so they work without template files.
|
|
35
|
+
`/df-status` and `/df-verify` read live in-memory state; `/df-profile`
|
|
36
|
+
updates the config and applies the change immediately; `/df-help` lists
|
|
37
|
+
the commands. Responses are posted as ignored messages so they do not get
|
|
38
|
+
re-processed as user input.
|
|
37
39
|
|
|
38
40
|
## Profiles
|
|
39
41
|
|
|
@@ -58,8 +60,8 @@ Then add it to your project's `opencode.json`:
|
|
|
58
60
|
}
|
|
59
61
|
```
|
|
60
62
|
|
|
61
|
-
Finally, scaffold the project-level files (agents, skills,
|
|
62
|
-
config) into your repo with the bundled `df` CLI:
|
|
63
|
+
Finally, scaffold the project-level files (agents, skills, local rules directory,
|
|
64
|
+
and default config) into your repo with the bundled `df` CLI:
|
|
63
65
|
|
|
64
66
|
```bash
|
|
65
67
|
npx df init # if installed locally as a project dependency
|
|
@@ -154,14 +156,16 @@ complete example.
|
|
|
154
156
|
|
|
155
157
|
## Slash commands
|
|
156
158
|
|
|
157
|
-
The
|
|
158
|
-
`df init` (or the `dev_framework_init` tool) into `.opencode/commands/`. Inside
|
|
159
|
-
an OpenCode session:
|
|
159
|
+
The plugin registers three slash commands directly (no template files required):
|
|
160
160
|
|
|
161
|
-
- `/df-
|
|
162
|
-
|
|
163
|
-
- `/df-
|
|
164
|
-
|
|
161
|
+
- `/df-status` — shows the current profile, guardrails, completion gate,
|
|
162
|
+
configured commands, and tracked changed files. Reads live in-memory state.
|
|
163
|
+
- `/df-verify` — runs the configured verification suite manually.
|
|
164
|
+
- `/df-profile <profile>` — changes the active profile and applies it
|
|
165
|
+
immediately.
|
|
166
|
+
|
|
167
|
+
You can still run `df init` to install the bundled agents, skills, and default
|
|
168
|
+
config; the commands themselves are provided by the plugin.
|
|
165
169
|
|
|
166
170
|
## Limitations
|
|
167
171
|
|
|
@@ -191,6 +195,12 @@ npm run test
|
|
|
191
195
|
npm run build
|
|
192
196
|
```
|
|
193
197
|
|
|
198
|
+
For persistent debug traces, set `OPENCODE_DEV_FRAMEWORK_LOG_FILE`:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
OPENCODE_DEV_FRAMEWORK_LOG_FILE=/tmp/odf.log opencode run
|
|
202
|
+
```
|
|
203
|
+
|
|
194
204
|
See `AGENTS.md` and `docs/plans/` for the architecture and implementation
|
|
195
205
|
plan.
|
|
196
206
|
|
package/bin/df
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// df — opencode-dev-framework CLI installer.
|
|
3
|
-
// Scaffold project-level agents, skills,
|
|
3
|
+
// Scaffold project-level agents, skills, local rules, and config into a repo.
|
|
4
4
|
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
@@ -56,6 +56,9 @@ async function main() {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
const flags = new Set(args.slice(1).filter((arg) => arg.startsWith("--")));
|
|
60
|
+
const positional = args.slice(1).filter((arg) => !arg.startsWith("--"));
|
|
61
|
+
|
|
59
62
|
if (command === "profile") {
|
|
60
63
|
const profile = positional[0];
|
|
61
64
|
const profileDir = resolveTargetDir(positional[1]);
|
|
@@ -79,8 +82,6 @@ async function main() {
|
|
|
79
82
|
return;
|
|
80
83
|
}
|
|
81
84
|
|
|
82
|
-
const flags = new Set(args.slice(1).filter((arg) => arg.startsWith("--")));
|
|
83
|
-
const positional = args.slice(1).filter((arg) => !arg.startsWith("--"));
|
|
84
85
|
const targetDir = resolveTargetDir(positional[0]);
|
|
85
86
|
|
|
86
87
|
if (command === "init" && flags.has("--skip-existing") && flags.has("--overwrite-existing")) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandMap } from "./types.js";
|
|
2
|
+
export interface NormalizedCommandMap {
|
|
3
|
+
default?: string;
|
|
4
|
+
byExtension: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Normalize a command map: a plain string becomes the default command; a record
|
|
8
|
+
* may contain a `default` key plus per-extension overrides.
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeCommandMap(map: CommandMap | undefined): NormalizedCommandMap;
|
|
11
|
+
/** Split a command string into argv tokens, honoring simple quotes. */
|
|
12
|
+
export declare function splitCommand(command: string): string[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a command map: a plain string becomes the default command; a record
|
|
3
|
+
* may contain a `default` key plus per-extension overrides.
|
|
4
|
+
*/
|
|
5
|
+
export function normalizeCommandMap(map) {
|
|
6
|
+
if (map === undefined) {
|
|
7
|
+
return { byExtension: {} };
|
|
8
|
+
}
|
|
9
|
+
if (typeof map === "string") {
|
|
10
|
+
return { default: map, byExtension: {} };
|
|
11
|
+
}
|
|
12
|
+
const { default: defaultCommand, ...byExtension } = map;
|
|
13
|
+
return defaultCommand === undefined ? { byExtension } : { default: defaultCommand, byExtension };
|
|
14
|
+
}
|
|
15
|
+
/** Split a command string into argv tokens, honoring simple quotes. */
|
|
16
|
+
export function splitCommand(command) {
|
|
17
|
+
const tokens = [];
|
|
18
|
+
let current = "";
|
|
19
|
+
let quote;
|
|
20
|
+
for (const ch of command) {
|
|
21
|
+
if (quote !== undefined) {
|
|
22
|
+
if (ch === quote) {
|
|
23
|
+
quote = undefined;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
current += ch;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (ch === '"' || ch === "'") {
|
|
30
|
+
quote = ch;
|
|
31
|
+
}
|
|
32
|
+
else if (/\s/.test(ch)) {
|
|
33
|
+
if (current !== "") {
|
|
34
|
+
tokens.push(current);
|
|
35
|
+
current = "";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
current += ch;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (current !== "") {
|
|
43
|
+
tokens.push(current);
|
|
44
|
+
}
|
|
45
|
+
return tokens;
|
|
46
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HookState } from "./registry.js";
|
|
2
|
+
import type { ResolvedConfig } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Render a human-readable summary of the current plugin state.
|
|
5
|
+
*
|
|
6
|
+
* Used by the `dev_framework_status` custom tool and by the `/df-status`
|
|
7
|
+
* slash-command handler.
|
|
8
|
+
*/
|
|
9
|
+
export declare function renderStatus(config: ResolvedConfig, state?: HookState | null): string;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
function formatCommandMap(map, indent) {
|
|
2
|
+
if (map === undefined) {
|
|
3
|
+
return `${indent}(not configured)`;
|
|
4
|
+
}
|
|
5
|
+
if (typeof map === "string") {
|
|
6
|
+
return `${indent}${map}`;
|
|
7
|
+
}
|
|
8
|
+
const entries = Object.entries(map);
|
|
9
|
+
if (entries.length === 0) {
|
|
10
|
+
return `${indent}(not configured)`;
|
|
11
|
+
}
|
|
12
|
+
return entries.map(([ext, cmd]) => `${indent}${ext}: ${cmd}`).join("\n");
|
|
13
|
+
}
|
|
14
|
+
function formatRules(rules) {
|
|
15
|
+
if (rules === undefined) {
|
|
16
|
+
return " (bundled rules)";
|
|
17
|
+
}
|
|
18
|
+
const lines = [` mode: ${rules.mode}`];
|
|
19
|
+
if (rules.files.length === 0) {
|
|
20
|
+
lines.push(" files: (none)");
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
lines.push(" files:");
|
|
24
|
+
for (const file of rules.files) {
|
|
25
|
+
lines.push(` - ${file}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return lines.join("\n");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Render a human-readable summary of the current plugin state.
|
|
32
|
+
*
|
|
33
|
+
* Used by the `dev_framework_status` custom tool and by the `/df-status`
|
|
34
|
+
* slash-command handler.
|
|
35
|
+
*/
|
|
36
|
+
export function renderStatus(config, state) {
|
|
37
|
+
const lines = [];
|
|
38
|
+
lines.push(`opencode-dev-framework status`);
|
|
39
|
+
lines.push("");
|
|
40
|
+
lines.push(`Profile: ${config.profile}`);
|
|
41
|
+
lines.push(`Config: ${config.configPath ?? "(none — defaults to off)"}`);
|
|
42
|
+
lines.push("");
|
|
43
|
+
lines.push("Guardrails:");
|
|
44
|
+
lines.push(` protect_mode: ${config.protect_mode}`);
|
|
45
|
+
lines.push(` protect_off: ${config.protect_off}`);
|
|
46
|
+
if (config.protect.length === 0) {
|
|
47
|
+
lines.push(" protected paths: (none)");
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
lines.push(" protected paths:");
|
|
51
|
+
for (const pattern of config.protect) {
|
|
52
|
+
lines.push(` - ${pattern}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
lines.push("");
|
|
56
|
+
lines.push("On edit:");
|
|
57
|
+
lines.push(` format: ${config.on_edit.format}`);
|
|
58
|
+
lines.push(` lint: ${config.on_edit.lint}`);
|
|
59
|
+
lines.push(` precommit: ${config.precommit}`);
|
|
60
|
+
if (state && config.precommit === "auto") {
|
|
61
|
+
lines.push(` pre-commit binary available: ${state.precommitAvailable === true ? "yes" : state.precommitAvailable === false ? "no" : "not checked yet"}`);
|
|
62
|
+
}
|
|
63
|
+
lines.push("");
|
|
64
|
+
lines.push("Completion gate:");
|
|
65
|
+
lines.push(` run_typecheck: ${config.gate.run_typecheck}`);
|
|
66
|
+
lines.push(` run_tests: ${config.gate.run_tests}`);
|
|
67
|
+
lines.push(` lint_changed: ${config.gate.lint_changed}`);
|
|
68
|
+
lines.push(` block_on_failure: ${config.gate.block_on_failure}`);
|
|
69
|
+
lines.push(` skip_unchanged: ${config.gate.skip_unchanged}`);
|
|
70
|
+
lines.push(` scope: ${config.gate.scope}`);
|
|
71
|
+
lines.push(` timeout: ${config.gate.timeout ?? "(default)"}`);
|
|
72
|
+
lines.push(` max_blocks: ${config.gate.max_blocks}`);
|
|
73
|
+
lines.push("");
|
|
74
|
+
lines.push("Commands:");
|
|
75
|
+
lines.push(" typecheck:");
|
|
76
|
+
lines.push(formatCommandMap(config.commands.typecheck, " "));
|
|
77
|
+
lines.push(" test:");
|
|
78
|
+
lines.push(formatCommandMap(config.commands.test, " "));
|
|
79
|
+
lines.push(" test_changed:");
|
|
80
|
+
lines.push(config.commands.test_changed ? ` ${config.commands.test_changed}` : " (not configured)");
|
|
81
|
+
lines.push(" lint:");
|
|
82
|
+
lines.push(formatCommandMap(config.commands.lint, " "));
|
|
83
|
+
lines.push(" format:");
|
|
84
|
+
lines.push(formatCommandMap(config.commands.format, " "));
|
|
85
|
+
lines.push("");
|
|
86
|
+
lines.push("Constitution rules:");
|
|
87
|
+
lines.push(formatRules(config.rules));
|
|
88
|
+
if (config.style_guide) {
|
|
89
|
+
lines.push(` style_guide: ${config.style_guide}`);
|
|
90
|
+
}
|
|
91
|
+
if (state) {
|
|
92
|
+
const changedFiles = state.tracker.getChangedFiles();
|
|
93
|
+
lines.push("");
|
|
94
|
+
lines.push(`Changed files tracked: ${changedFiles.length}`);
|
|
95
|
+
if (changedFiles.length > 0) {
|
|
96
|
+
for (const file of changedFiles) {
|
|
97
|
+
lines.push(` - ${file}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (state.blockCounts.size > 0) {
|
|
101
|
+
lines.push("");
|
|
102
|
+
lines.push("Completion gate blocks this session:");
|
|
103
|
+
for (const [sessionID, count] of state.blockCounts) {
|
|
104
|
+
lines.push(` ${sessionID}: ${count}/${config.gate.max_blocks}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return lines.join("\n");
|
|
109
|
+
}
|
package/dist/gate.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* then the agent's turn has already finished, so failures cannot block.
|
|
10
10
|
*/
|
|
11
11
|
import { isAbsolute, relative } from "node:path";
|
|
12
|
-
import { splitCommand } from "./
|
|
12
|
+
import { splitCommand } from "./command-utils.js";
|
|
13
13
|
import { lintFile } from "./lint.js";
|
|
14
14
|
/** Fallback per-command timeout (seconds) when `gate.timeout` is unset. */
|
|
15
15
|
export const DEFAULT_GATE_TIMEOUT_SECONDS = 300;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,12 +7,14 @@
|
|
|
7
7
|
* - event (session.idle) -> completion gate fallback (advisory logging)
|
|
8
8
|
* - experimental.chat.system.transform -> constitution injection + session mapping
|
|
9
9
|
* - experimental.session.stopping -> blocking completion gate (OpenCode >= PR #41811)
|
|
10
|
-
* -
|
|
10
|
+
* - config hook -> registers /df-status, /df-verify, /df-profile slash commands
|
|
11
|
+
* - command.execute.before -> handles those slash commands directly
|
|
11
12
|
*/
|
|
12
13
|
import type { Hooks, Plugin, PluginInput } from "@opencode-ai/plugin";
|
|
13
14
|
import { type ChangedFileTracker } from "./gate.js";
|
|
14
15
|
import { type RunCommand } from "./host.js";
|
|
15
16
|
import { type LogFn } from "./logger.js";
|
|
17
|
+
import { type SendMessageFn } from "./messenger.js";
|
|
16
18
|
import type { ResolvedConfig } from "./types.js";
|
|
17
19
|
/**
|
|
18
20
|
* The `experimental.session.stopping` hook was added in OpenCode PR #41811
|
|
@@ -31,6 +33,6 @@ export interface HooksWithStopping extends Hooks {
|
|
|
31
33
|
* Build the plugin's hooks and custom tools. Exported (rather than inlined in
|
|
32
34
|
* the plugin) so tests can inject a stubbed command runner and tracker.
|
|
33
35
|
*/
|
|
34
|
-
export declare function buildHooks(ctx: PluginInput, config: ResolvedConfig, log: LogFn, run?: RunCommand, tracker?: ChangedFileTracker, constitution?: string | null): HooksWithStopping;
|
|
36
|
+
export declare function buildHooks(ctx: PluginInput, config: ResolvedConfig, log: LogFn, run?: RunCommand, tracker?: ChangedFileTracker, constitution?: string | null, sendMessage?: SendMessageFn | null): HooksWithStopping;
|
|
35
37
|
export declare const devFramework: Plugin;
|
|
36
38
|
export default devFramework;
|
package/dist/index.js
CHANGED
|
@@ -7,22 +7,27 @@
|
|
|
7
7
|
* - event (session.idle) -> completion gate fallback (advisory logging)
|
|
8
8
|
* - experimental.chat.system.transform -> constitution injection + session mapping
|
|
9
9
|
* - experimental.session.stopping -> blocking completion gate (OpenCode >= PR #41811)
|
|
10
|
-
* -
|
|
10
|
+
* - config hook -> registers /df-status, /df-verify, /df-profile slash commands
|
|
11
|
+
* - command.execute.before -> handles those slash commands directly
|
|
11
12
|
*/
|
|
12
|
-
import {
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { clearConfigCache, loadConfig } from "./config.js";
|
|
13
15
|
import { createChangedFileTracker, runGate, summarizeGate, } from "./gate.js";
|
|
16
|
+
import { renderStatus } from "./format-status.js";
|
|
14
17
|
import { runCommand } from "./host.js";
|
|
15
18
|
import { detectPreCommitAvailability, isLintFailure, lintFile, summarizeLint } from "./lint.js";
|
|
16
19
|
import { createLogger } from "./logger.js";
|
|
20
|
+
import { createMessenger } from "./messenger.js";
|
|
17
21
|
import { checkToolCall } from "./protect.js";
|
|
18
|
-
import { clearSessionDirectory,
|
|
22
|
+
import { clearSessionDirectory, getHookState, getStateForSession, setBaseDirectory, setHookState, setSessionDirectory, updateHookState, } from "./registry.js";
|
|
19
23
|
import { injectConstitution, loadConstitution } from "./rules.js";
|
|
24
|
+
import { setProfileInFile } from "./installer.js";
|
|
20
25
|
import { buildTools } from "./tools.js";
|
|
21
26
|
/**
|
|
22
27
|
* Build the plugin's hooks and custom tools. Exported (rather than inlined in
|
|
23
28
|
* the plugin) so tests can inject a stubbed command runner and tracker.
|
|
24
29
|
*/
|
|
25
|
-
export function buildHooks(ctx, config, log, run = runCommand, tracker = createChangedFileTracker(), constitution = null) {
|
|
30
|
+
export function buildHooks(ctx, config, log, run = runCommand, tracker = createChangedFileTracker(), constitution = null, sendMessage = createMessenger(ctx.client)) {
|
|
26
31
|
// All hook state — including the project directory — lives in the registry
|
|
27
32
|
// and is looked up at call time. OpenCode's Effect runtime stripped closure
|
|
28
33
|
// captures in production (config/log/run came back undefined), so hooks must
|
|
@@ -35,11 +40,110 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
35
40
|
tracker,
|
|
36
41
|
constitution,
|
|
37
42
|
blockCounts: new Map(),
|
|
43
|
+
sendMessage,
|
|
38
44
|
});
|
|
39
45
|
return {
|
|
40
46
|
tool: buildTools(ctx),
|
|
47
|
+
config: async (opencodeConfig) => {
|
|
48
|
+
const typedConfig = opencodeConfig;
|
|
49
|
+
const state = getHookState(ctx.directory);
|
|
50
|
+
if (state) {
|
|
51
|
+
state.hostPermissions = typedConfig.permission ?? [];
|
|
52
|
+
}
|
|
53
|
+
if (!typedConfig.command) {
|
|
54
|
+
typedConfig.command = {};
|
|
55
|
+
}
|
|
56
|
+
typedConfig.command["df-status"] = {
|
|
57
|
+
template: "",
|
|
58
|
+
description: "Show the current dev-framework state",
|
|
59
|
+
};
|
|
60
|
+
typedConfig.command["df-profile"] = {
|
|
61
|
+
template: "",
|
|
62
|
+
description: "Change the dev-framework profile (off, advisory, standard, strict)",
|
|
63
|
+
};
|
|
64
|
+
typedConfig.command["df-verify"] = {
|
|
65
|
+
template: "",
|
|
66
|
+
description: "Run the dev-framework completion gate manually",
|
|
67
|
+
};
|
|
68
|
+
typedConfig.command["df-help"] = {
|
|
69
|
+
template: "",
|
|
70
|
+
description: "List the available dev-framework slash commands",
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
"command.execute.before": async (input, output) => {
|
|
74
|
+
const state = getStateForSession(input.sessionID);
|
|
75
|
+
if (!state) {
|
|
76
|
+
const fallback = "[opencode-dev-framework] plugin state is not available for this session.";
|
|
77
|
+
output.parts.length = 0;
|
|
78
|
+
output.parts.push({ type: "text", text: fallback });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const directory = state.directory;
|
|
82
|
+
const reply = async (text) => {
|
|
83
|
+
if (state.sendMessage) {
|
|
84
|
+
output.parts.length = 0;
|
|
85
|
+
await state.sendMessage(input.sessionID, text);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
output.parts.length = 0;
|
|
89
|
+
output.parts.push({ type: "text", text });
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
if (input.command === "df-help" || input.command === "df") {
|
|
93
|
+
await reply(`df — opencode-dev-framework commands
|
|
94
|
+
|
|
95
|
+
/df-status Show the current dev-framework state
|
|
96
|
+
/df-profile Change the profile to off, advisory, standard, or strict
|
|
97
|
+
/df-verify Run the completion gate manually
|
|
98
|
+
/df-help Show this message`);
|
|
99
|
+
await state.log("info", "df-help command executed", { directory });
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (input.command === "df-status") {
|
|
103
|
+
await reply(renderStatus(state.config, state));
|
|
104
|
+
await state.log("info", "df-status command executed", { directory });
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (input.command === "df-profile") {
|
|
108
|
+
const profile = input.arguments.trim().toLowerCase();
|
|
109
|
+
const validProfiles = ["off", "advisory", "standard", "strict"];
|
|
110
|
+
if (!validProfiles.includes(profile)) {
|
|
111
|
+
await reply(`Invalid profile "${profile}". Valid values: ${validProfiles.join(", ")}.`);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const configPath = join(state.directory, ".opencode-dev-framework.yml");
|
|
115
|
+
await setProfileInFile(configPath, profile);
|
|
116
|
+
clearConfigCache();
|
|
117
|
+
const nextConfig = loadConfig(state.directory);
|
|
118
|
+
const { constitution } = await loadConstitution(nextConfig, state.directory);
|
|
119
|
+
updateHookState(state.directory, { config: nextConfig, constitution });
|
|
120
|
+
await reply(`opencode-dev-framework profile set to "${profile}". Change applied immediately.`);
|
|
121
|
+
await state.log("info", "df-profile command executed", { directory, profile });
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (input.command === "df-verify") {
|
|
125
|
+
const changedFiles = state.tracker.getChangedFiles();
|
|
126
|
+
const report = await runGate(state.run, state.config, changedFiles, {
|
|
127
|
+
cwd: state.directory,
|
|
128
|
+
});
|
|
129
|
+
const summary = summarizeGate(report);
|
|
130
|
+
await reply(summary);
|
|
131
|
+
const level = report.ok ? "info" : "error";
|
|
132
|
+
await state.log(level, "df-verify command executed", {
|
|
133
|
+
directory,
|
|
134
|
+
ok: report.ok,
|
|
135
|
+
ran: report.ran,
|
|
136
|
+
});
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
// Unknown /df-* command — give a helpful response.
|
|
140
|
+
if (input.command.startsWith("df-")) {
|
|
141
|
+
await reply(`Unknown command /${input.command}. Try /df-help.`);
|
|
142
|
+
await state.log("warn", "unknown df command", { directory, command: input.command });
|
|
143
|
+
}
|
|
144
|
+
},
|
|
41
145
|
"experimental.chat.system.transform": async (input, output) => {
|
|
42
|
-
const state =
|
|
146
|
+
const state = getStateForSession(input.sessionID);
|
|
43
147
|
if (!state) {
|
|
44
148
|
return;
|
|
45
149
|
}
|
|
@@ -53,11 +157,11 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
53
157
|
}
|
|
54
158
|
},
|
|
55
159
|
"tool.execute.before": async (input, output) => {
|
|
56
|
-
const state =
|
|
160
|
+
const state = getStateForSession(input.sessionID);
|
|
57
161
|
if (!state) {
|
|
58
|
-
|
|
162
|
+
throw new Error("[opencode-dev-framework] plugin state is not available; guardrail cannot evaluate this tool call");
|
|
59
163
|
}
|
|
60
|
-
const result = checkToolCall(state.config, input.tool, output.args, state.directory);
|
|
164
|
+
const result = checkToolCall(state.config, input.tool, output.args, state.directory, state.hostPermissions);
|
|
61
165
|
if (result.decision === "allow") {
|
|
62
166
|
return;
|
|
63
167
|
}
|
|
@@ -75,7 +179,7 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
75
179
|
throw new Error(`[opencode-dev-framework] ${message}`);
|
|
76
180
|
},
|
|
77
181
|
"experimental.session.stopping": async (input, output) => {
|
|
78
|
-
const state =
|
|
182
|
+
const state = getStateForSession(input.sessionID);
|
|
79
183
|
if (!state?.config.gate || state.config.profile === "off") {
|
|
80
184
|
return;
|
|
81
185
|
}
|
|
@@ -111,9 +215,10 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
111
215
|
clearSessionDirectory(event.properties.info.id);
|
|
112
216
|
return;
|
|
113
217
|
}
|
|
114
|
-
const
|
|
115
|
-
?
|
|
116
|
-
: undefined
|
|
218
|
+
const sessionID = event.type === "session.idle"
|
|
219
|
+
? event.properties.sessionID
|
|
220
|
+
: undefined;
|
|
221
|
+
const state = getStateForSession(sessionID);
|
|
117
222
|
if (!state) {
|
|
118
223
|
return;
|
|
119
224
|
}
|
|
@@ -193,12 +298,31 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
193
298
|
};
|
|
194
299
|
}
|
|
195
300
|
export const devFramework = async (ctx) => {
|
|
196
|
-
const
|
|
301
|
+
const log = createLogger(ctx.client);
|
|
302
|
+
let config;
|
|
303
|
+
try {
|
|
304
|
+
config = loadConfig(ctx.directory);
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
308
|
+
await log("error", message, { directory: ctx.directory });
|
|
309
|
+
const clientTui = ctx.client.tui;
|
|
310
|
+
try {
|
|
311
|
+
await clientTui?.showToast?.({
|
|
312
|
+
type: "error",
|
|
313
|
+
message: `[opencode-dev-framework] ${message}`,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
// TUI may not be available; the log line is enough.
|
|
318
|
+
}
|
|
319
|
+
return {};
|
|
320
|
+
}
|
|
197
321
|
// The off profile registers no hooks at all.
|
|
198
322
|
if (config.profile === "off") {
|
|
199
323
|
return {};
|
|
200
324
|
}
|
|
201
|
-
|
|
325
|
+
setBaseDirectory(ctx.directory);
|
|
202
326
|
const { constitution, warning } = await loadConstitution(config, ctx.directory);
|
|
203
327
|
if (warning) {
|
|
204
328
|
await log("warn", warning);
|
package/dist/installer.js
CHANGED
|
@@ -2,6 +2,7 @@ import { promises as fs } from "node:fs";
|
|
|
2
2
|
import { dirname, join, resolve } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { createInterface } from "node:readline";
|
|
5
|
+
import { DEFAULT_PROTECT } from "./config.js";
|
|
5
6
|
import { detectProject } from "./detect.js";
|
|
6
7
|
/** Directory containing the project templates shipped with the package. */
|
|
7
8
|
export const TEMPLATES_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "templates");
|
|
@@ -150,7 +151,6 @@ export async function statusTemplates(targetDir) {
|
|
|
150
151
|
}
|
|
151
152
|
return status;
|
|
152
153
|
}
|
|
153
|
-
const DEFAULT_PROTECT = [".env*", "**/.env*", "**/node_modules/**", "**/vendor/**"];
|
|
154
154
|
function buildDefaultConfigYaml(language, commands, hasPreCommitConfig) {
|
|
155
155
|
const lines = ["# opencode-dev-framework configuration"];
|
|
156
156
|
lines.push("# Edit the commands to match your project's toolchain.");
|
package/dist/lint.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { basename, extname, isAbsolute, relative } from "node:path";
|
|
7
7
|
import picomatch from "picomatch";
|
|
8
|
-
import { normalizeCommandMap, splitCommand } from "./
|
|
8
|
+
import { normalizeCommandMap, splitCommand } from "./command-utils.js";
|
|
9
9
|
/** Fallback per-lint timeout (seconds) when the config sets none. */
|
|
10
10
|
export const DEFAULT_LINT_TIMEOUT_SECONDS = 60;
|
|
11
11
|
/**
|
package/dist/logger.d.ts
CHANGED
|
@@ -10,5 +10,9 @@ export type LogFn = (level: LogLevel, message: string, extra?: Record<string, un
|
|
|
10
10
|
* `app.log` failures fall back to stderr so the failure stays visible
|
|
11
11
|
* (a total swallow made production debugging painful during development),
|
|
12
12
|
* and even stderr failures are ignored as a last resort.
|
|
13
|
+
*
|
|
14
|
+
* If the `OPENCODE_DEV_FRAMEWORK_LOG_FILE` environment variable is set, every
|
|
15
|
+
* log line is also appended to that path as JSON, which is useful when
|
|
16
|
+
* `app.log` is unavailable or when a persistent trace is needed.
|
|
13
17
|
*/
|
|
14
18
|
export declare function createLogger(client: PluginInput["client"]): LogFn;
|
package/dist/logger.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Structured logging wrapper around the OpenCode client's app.log API.
|
|
3
3
|
*/
|
|
4
|
+
import { appendFile } from "node:fs/promises";
|
|
4
5
|
export const LOG_SERVICE = "opencode-dev-framework";
|
|
5
6
|
/**
|
|
6
7
|
* Create a logger bound to the OpenCode client. Logging never throws:
|
|
7
8
|
* `app.log` failures fall back to stderr so the failure stays visible
|
|
8
9
|
* (a total swallow made production debugging painful during development),
|
|
9
10
|
* and even stderr failures are ignored as a last resort.
|
|
11
|
+
*
|
|
12
|
+
* If the `OPENCODE_DEV_FRAMEWORK_LOG_FILE` environment variable is set, every
|
|
13
|
+
* log line is also appended to that path as JSON, which is useful when
|
|
14
|
+
* `app.log` is unavailable or when a persistent trace is needed.
|
|
10
15
|
*/
|
|
11
16
|
export function createLogger(client) {
|
|
17
|
+
const filePath = process.env.OPENCODE_DEV_FRAMEWORK_LOG_FILE;
|
|
12
18
|
return async (level, message, extra) => {
|
|
19
|
+
const line = JSON.stringify({
|
|
20
|
+
timestamp: new Date().toISOString(),
|
|
21
|
+
service: LOG_SERVICE,
|
|
22
|
+
level,
|
|
23
|
+
message,
|
|
24
|
+
extra,
|
|
25
|
+
});
|
|
13
26
|
try {
|
|
14
27
|
await client.app.log({ body: { service: LOG_SERVICE, level, message, extra } });
|
|
15
28
|
}
|
|
@@ -21,5 +34,13 @@ export function createLogger(client) {
|
|
|
21
34
|
// Even stderr may be unavailable; truly ignore.
|
|
22
35
|
}
|
|
23
36
|
}
|
|
37
|
+
if (filePath) {
|
|
38
|
+
try {
|
|
39
|
+
await appendFile(filePath, `${line}\n`);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// File logging is best-effort.
|
|
43
|
+
}
|
|
44
|
+
}
|
|
24
45
|
};
|
|
25
46
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
export type SendMessageFn = (sessionID: string, text: string) => Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* Create a messenger that posts a chat message without it being treated as a
|
|
5
|
+
* user turn. OpenCode's `client.session.prompt` with `noReply: true` and an
|
|
6
|
+
* `ignored: true` text part shows the message in the conversation UI but does
|
|
7
|
+
* not feed it back to the model as input.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createMessenger(client: PluginInput["client"]): SendMessageFn;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a messenger that posts a chat message without it being treated as a
|
|
3
|
+
* user turn. OpenCode's `client.session.prompt` with `noReply: true` and an
|
|
4
|
+
* `ignored: true` text part shows the message in the conversation UI but does
|
|
5
|
+
* not feed it back to the model as input.
|
|
6
|
+
*/
|
|
7
|
+
export function createMessenger(client) {
|
|
8
|
+
const typedClient = client;
|
|
9
|
+
const prompt = typedClient?.session?.prompt;
|
|
10
|
+
if (!prompt) {
|
|
11
|
+
return async () => { };
|
|
12
|
+
}
|
|
13
|
+
return async (sessionID, text) => {
|
|
14
|
+
await prompt({
|
|
15
|
+
path: { id: sessionID },
|
|
16
|
+
body: {
|
|
17
|
+
noReply: true,
|
|
18
|
+
parts: [
|
|
19
|
+
{
|
|
20
|
+
type: "text",
|
|
21
|
+
text,
|
|
22
|
+
ignored: true,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
}
|
package/dist/protect.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* shell commands. Pure functions — the OpenCode hook wiring lives in
|
|
4
4
|
* src/index.ts.
|
|
5
5
|
*/
|
|
6
|
+
import type { HostPermission } from "./registry.js";
|
|
6
7
|
import type { ResolvedConfig } from "./types.js";
|
|
7
8
|
export type GuardDecision = "allow" | "warn" | "deny";
|
|
8
9
|
export interface GuardResult {
|
|
@@ -40,4 +41,4 @@ export declare function matchDangerousCommand(command: string): DangerousCommand
|
|
|
40
41
|
* `protect_off: true`), when the tool is not guarded, or when nothing
|
|
41
42
|
* matched. Otherwise returns `deny` or `warn` per `protect_mode`.
|
|
42
43
|
*/
|
|
43
|
-
export declare function checkToolCall(config: ResolvedConfig, tool: string, args: unknown, directory?: string): GuardResult;
|
|
44
|
+
export declare function checkToolCall(config: ResolvedConfig, tool: string, args: unknown, directory?: string, hostPermissions?: HostPermission[]): GuardResult;
|
package/dist/protect.js
CHANGED
|
@@ -79,6 +79,45 @@ export function matchProtectedPath(config, filePath, directory) {
|
|
|
79
79
|
export function matchDangerousCommand(command) {
|
|
80
80
|
return DANGEROUS_COMMANDS.find(({ pattern }) => pattern.test(command));
|
|
81
81
|
}
|
|
82
|
+
function permissionMatchesTool(permission, tool) {
|
|
83
|
+
if (permission === "*" || permission === tool) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (permission === "edit" && FILE_TOOLS.has(tool)) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
if (permission === "bash" && SHELL_TOOLS.has(tool)) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
/** Check whether the host OpenCode config already denies this tool/target. */
|
|
95
|
+
function hostDenies(tool, target, directory, hostPermissions) {
|
|
96
|
+
if (!hostPermissions || hostPermissions.length === 0) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
for (const perm of hostPermissions) {
|
|
100
|
+
if (perm.action !== "deny") {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (perm.permission && !permissionMatchesTool(perm.permission, tool)) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (perm.pattern) {
|
|
107
|
+
const matcher = picomatch(perm.pattern, { dot: true });
|
|
108
|
+
let candidate = target;
|
|
109
|
+
if (directory !== undefined && isAbsolute(target)) {
|
|
110
|
+
candidate = relative(directory, target);
|
|
111
|
+
}
|
|
112
|
+
candidate = candidate.replace(/^\.\//, "");
|
|
113
|
+
if (!matcher(candidate) && !matcher(basename(candidate))) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
82
121
|
function enforce(config, reason, matchedPattern) {
|
|
83
122
|
if (config.protect_mode === "deny") {
|
|
84
123
|
return { decision: "deny", reason, matchedPattern };
|
|
@@ -92,7 +131,7 @@ function enforce(config, reason, matchedPattern) {
|
|
|
92
131
|
* `protect_off: true`), when the tool is not guarded, or when nothing
|
|
93
132
|
* matched. Otherwise returns `deny` or `warn` per `protect_mode`.
|
|
94
133
|
*/
|
|
95
|
-
export function checkToolCall(config, tool, args, directory) {
|
|
134
|
+
export function checkToolCall(config, tool, args, directory, hostPermissions) {
|
|
96
135
|
if (config.profile === "off" || config.protect_off) {
|
|
97
136
|
return { decision: "allow" };
|
|
98
137
|
}
|
|
@@ -101,6 +140,11 @@ export function checkToolCall(config, tool, args, directory) {
|
|
|
101
140
|
if (filePath === undefined) {
|
|
102
141
|
return { decision: "allow" };
|
|
103
142
|
}
|
|
143
|
+
// If the host permission model already denies this path, do not duplicate
|
|
144
|
+
// the block here.
|
|
145
|
+
if (hostDenies(tool, filePath, directory, hostPermissions)) {
|
|
146
|
+
return { decision: "allow" };
|
|
147
|
+
}
|
|
104
148
|
const pattern = matchProtectedPath(config, filePath, directory);
|
|
105
149
|
if (pattern !== undefined) {
|
|
106
150
|
return enforce(config, `${tool} on protected path "${filePath}" is blocked (matched "${pattern}")`, pattern);
|
|
@@ -112,6 +156,9 @@ export function checkToolCall(config, tool, args, directory) {
|
|
|
112
156
|
if (command === undefined) {
|
|
113
157
|
return { decision: "allow" };
|
|
114
158
|
}
|
|
159
|
+
if (hostDenies(tool, command, directory, hostPermissions)) {
|
|
160
|
+
return { decision: "allow" };
|
|
161
|
+
}
|
|
115
162
|
const dangerous = matchDangerousCommand(command);
|
|
116
163
|
if (dangerous !== undefined) {
|
|
117
164
|
return enforce(config, `bash command blocked: ${dangerous.reason}`, dangerous.pattern.source);
|
package/dist/registry.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { ChangedFileTracker } from "./gate.js";
|
|
2
2
|
import type { RunCommand } from "./host.js";
|
|
3
3
|
import type { LogFn } from "./logger.js";
|
|
4
|
+
import type { SendMessageFn } from "./messenger.js";
|
|
4
5
|
import type { ResolvedConfig } from "./types.js";
|
|
6
|
+
export interface HostPermission {
|
|
7
|
+
permission?: string;
|
|
8
|
+
pattern?: string;
|
|
9
|
+
action?: "allow" | "deny" | "ask";
|
|
10
|
+
}
|
|
5
11
|
export interface HookState {
|
|
6
12
|
/** Project directory this state belongs to. Stored here (rather than
|
|
7
13
|
* closure-captured by hooks) so every hook invocation is self-contained. */
|
|
@@ -15,9 +21,16 @@ export interface HookState {
|
|
|
15
21
|
blockCounts: Map<string, number>;
|
|
16
22
|
/** Cached result of checking whether `pre-commit` is available. */
|
|
17
23
|
precommitAvailable?: boolean;
|
|
24
|
+
/** Snapshot of host permissions from OpenCode's effective config. */
|
|
25
|
+
hostPermissions?: HostPermission[];
|
|
26
|
+
/** Messenger for posting ignored chat messages from slash commands. */
|
|
27
|
+
sendMessage?: SendMessageFn | null;
|
|
18
28
|
}
|
|
29
|
+
export declare function setBaseDirectory(directory: string): void;
|
|
30
|
+
export declare function getBaseDirectory(): string | null;
|
|
19
31
|
export declare function setHookState(directory: string, state: HookState): void;
|
|
20
32
|
export declare function getHookState(directoryHint?: string): HookState | null;
|
|
33
|
+
export declare function getStateForSession(sessionID: string | undefined): HookState | null;
|
|
21
34
|
export declare function updateHookState(directory: string, updates: Partial<HookState>): HookState | null;
|
|
22
35
|
export declare function setSessionDirectory(sessionID: string, directory: string): void;
|
|
23
36
|
export declare function getDirectoryForSession(sessionID: string): string | null;
|
package/dist/registry.js
CHANGED
|
@@ -1,21 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-directory hook state registry. OpenCode's effect runtime can strip
|
|
3
3
|
* closure variables when invoking hooks asynchronously, so we store the state
|
|
4
|
-
* in module-level maps and look
|
|
4
|
+
* in module-level maps and look up values at call time.
|
|
5
|
+
*
|
|
6
|
+
* `baseDirectory` is the project root set at plugin initialization. Hooks that
|
|
7
|
+
* receive only a session ID can fall back to this directory when the session
|
|
8
|
+
* has not been mapped yet.
|
|
5
9
|
*/
|
|
6
10
|
const hookRegistry = new Map();
|
|
7
11
|
let activeDirectory = null;
|
|
12
|
+
let baseDirectory = null;
|
|
13
|
+
export function setBaseDirectory(directory) {
|
|
14
|
+
baseDirectory = directory;
|
|
15
|
+
}
|
|
16
|
+
export function getBaseDirectory() {
|
|
17
|
+
return baseDirectory;
|
|
18
|
+
}
|
|
8
19
|
export function setHookState(directory, state) {
|
|
9
20
|
hookRegistry.set(directory, state);
|
|
10
21
|
activeDirectory = directory;
|
|
11
22
|
}
|
|
12
23
|
export function getHookState(directoryHint) {
|
|
13
|
-
const directory = directoryHint ?? activeDirectory;
|
|
24
|
+
const directory = directoryHint ?? activeDirectory ?? baseDirectory;
|
|
14
25
|
if (!directory) {
|
|
15
26
|
return null;
|
|
16
27
|
}
|
|
17
28
|
return hookRegistry.get(directory) ?? null;
|
|
18
29
|
}
|
|
30
|
+
export function getStateForSession(sessionID) {
|
|
31
|
+
if (sessionID) {
|
|
32
|
+
const mapped = getDirectoryForSession(sessionID);
|
|
33
|
+
if (mapped) {
|
|
34
|
+
return getHookState(mapped);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return getHookState(baseDirectory ?? undefined);
|
|
38
|
+
}
|
|
19
39
|
export function updateHookState(directory, updates) {
|
|
20
40
|
const state = hookRegistry.get(directory);
|
|
21
41
|
if (!state) {
|
package/dist/rules.d.ts
CHANGED
|
@@ -38,7 +38,8 @@ export interface ConstitutionResult {
|
|
|
38
38
|
*/
|
|
39
39
|
export declare function loadConstitution(config: ResolvedConfig, directory?: string): Promise<ConstitutionResult>;
|
|
40
40
|
/**
|
|
41
|
-
* Appends the constitution to
|
|
42
|
-
* present
|
|
41
|
+
* Appends the constitution to the last system-prompt entry, unless it is already
|
|
42
|
+
* present. This keeps the system prompt compact instead of adding a separate
|
|
43
|
+
* array element each time the transform runs.
|
|
43
44
|
*/
|
|
44
45
|
export declare function injectConstitution(system: string[], constitution: string | null): string[];
|
package/dist/rules.js
CHANGED
|
@@ -170,8 +170,9 @@ export async function loadConstitution(config, directory) {
|
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
|
-
* Appends the constitution to
|
|
174
|
-
* present
|
|
173
|
+
* Appends the constitution to the last system-prompt entry, unless it is already
|
|
174
|
+
* present. This keeps the system prompt compact instead of adding a separate
|
|
175
|
+
* array element each time the transform runs.
|
|
175
176
|
*/
|
|
176
177
|
export function injectConstitution(system, constitution) {
|
|
177
178
|
if (constitution === null) {
|
|
@@ -180,5 +181,10 @@ export function injectConstitution(system, constitution) {
|
|
|
180
181
|
if (system.some((entry) => entry.includes(constitution))) {
|
|
181
182
|
return system;
|
|
182
183
|
}
|
|
183
|
-
|
|
184
|
+
if (system.length === 0) {
|
|
185
|
+
return [constitution];
|
|
186
|
+
}
|
|
187
|
+
const next = [...system];
|
|
188
|
+
next[next.length - 1] = `${next[next.length - 1]}\n\n${constitution}`;
|
|
189
|
+
return next;
|
|
184
190
|
}
|
package/dist/tools.js
CHANGED
|
@@ -4,39 +4,11 @@ import { loadConfig, clearConfigCache } from "./config.js";
|
|
|
4
4
|
import { installTemplates, setProfileInFile, writeDetectedConfig } from "./installer.js";
|
|
5
5
|
import { getHookState, updateHookState } from "./registry.js";
|
|
6
6
|
import { loadConstitution } from "./rules.js";
|
|
7
|
+
import { renderStatus } from "./format-status.js";
|
|
7
8
|
const PROFILES = ["off", "advisory", "standard", "strict"];
|
|
8
9
|
function isProfile(value) {
|
|
9
10
|
return PROFILES.includes(value);
|
|
10
11
|
}
|
|
11
|
-
function formatCommandMap(map, indent) {
|
|
12
|
-
if (map === undefined) {
|
|
13
|
-
return `${indent}(not configured)`;
|
|
14
|
-
}
|
|
15
|
-
if (typeof map === "string") {
|
|
16
|
-
return `${indent}${map}`;
|
|
17
|
-
}
|
|
18
|
-
const entries = Object.entries(map);
|
|
19
|
-
if (entries.length === 0) {
|
|
20
|
-
return `${indent}(not configured)`;
|
|
21
|
-
}
|
|
22
|
-
return entries.map(([ext, cmd]) => `${indent}${ext}: ${cmd}`).join("\n");
|
|
23
|
-
}
|
|
24
|
-
function formatRules(rules) {
|
|
25
|
-
if (rules === undefined) {
|
|
26
|
-
return " (bundled rules)";
|
|
27
|
-
}
|
|
28
|
-
const lines = [` mode: ${rules.mode}`];
|
|
29
|
-
if (rules.files.length === 0) {
|
|
30
|
-
lines.push(" files: (none)");
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
lines.push(" files:");
|
|
34
|
-
for (const file of rules.files) {
|
|
35
|
-
lines.push(` - ${file}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return lines.join("\n");
|
|
39
|
-
}
|
|
40
12
|
export function buildTools(_ctx) {
|
|
41
13
|
return {
|
|
42
14
|
dev_framework_init: tool({
|
|
@@ -117,80 +89,7 @@ export function buildTools(_ctx) {
|
|
|
117
89
|
const targetDir = args.directory ?? context.directory;
|
|
118
90
|
const state = getHookState(targetDir);
|
|
119
91
|
const config = state?.config ?? loadConfig(targetDir);
|
|
120
|
-
|
|
121
|
-
lines.push(`opencode-dev-framework status for ${targetDir}`);
|
|
122
|
-
lines.push("");
|
|
123
|
-
lines.push(`Profile: ${config.profile}`);
|
|
124
|
-
lines.push(`Config: ${config.configPath ?? "(none — defaults to off)"}`);
|
|
125
|
-
lines.push("");
|
|
126
|
-
lines.push("Guardrails:");
|
|
127
|
-
lines.push(` protect_mode: ${config.protect_mode}`);
|
|
128
|
-
lines.push(` protect_off: ${config.protect_off}`);
|
|
129
|
-
if (config.protect.length === 0) {
|
|
130
|
-
lines.push(" protected paths: (none)");
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
lines.push(" protected paths:");
|
|
134
|
-
for (const pattern of config.protect) {
|
|
135
|
-
lines.push(` - ${pattern}`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
lines.push("");
|
|
139
|
-
lines.push("On edit:");
|
|
140
|
-
lines.push(` format: ${config.on_edit.format}`);
|
|
141
|
-
lines.push(` lint: ${config.on_edit.lint}`);
|
|
142
|
-
lines.push(` precommit: ${config.precommit}`);
|
|
143
|
-
if (state && config.precommit === "auto") {
|
|
144
|
-
lines.push(` pre-commit binary available: ${state.precommitAvailable === true ? "yes" : state.precommitAvailable === false ? "no" : "not checked yet"}`);
|
|
145
|
-
}
|
|
146
|
-
lines.push("");
|
|
147
|
-
lines.push("Completion gate:");
|
|
148
|
-
lines.push(` run_typecheck: ${config.gate.run_typecheck}`);
|
|
149
|
-
lines.push(` run_tests: ${config.gate.run_tests}`);
|
|
150
|
-
lines.push(` lint_changed: ${config.gate.lint_changed}`);
|
|
151
|
-
lines.push(` block_on_failure: ${config.gate.block_on_failure}`);
|
|
152
|
-
lines.push(` skip_unchanged: ${config.gate.skip_unchanged}`);
|
|
153
|
-
lines.push(` scope: ${config.gate.scope}`);
|
|
154
|
-
lines.push(` timeout: ${config.gate.timeout ?? "(default)"}`);
|
|
155
|
-
lines.push(` max_blocks: ${config.gate.max_blocks}`);
|
|
156
|
-
lines.push("");
|
|
157
|
-
lines.push("Commands:");
|
|
158
|
-
lines.push(` typecheck:`);
|
|
159
|
-
lines.push(formatCommandMap(config.commands.typecheck, " "));
|
|
160
|
-
lines.push(` test:`);
|
|
161
|
-
lines.push(formatCommandMap(config.commands.test, " "));
|
|
162
|
-
lines.push(` test_changed:`);
|
|
163
|
-
lines.push(config.commands.test_changed
|
|
164
|
-
? ` ${config.commands.test_changed}`
|
|
165
|
-
: " (not configured)");
|
|
166
|
-
lines.push(` lint:`);
|
|
167
|
-
lines.push(formatCommandMap(config.commands.lint, " "));
|
|
168
|
-
lines.push(` format:`);
|
|
169
|
-
lines.push(formatCommandMap(config.commands.format, " "));
|
|
170
|
-
lines.push("");
|
|
171
|
-
lines.push("Constitution rules:");
|
|
172
|
-
lines.push(formatRules(config.rules));
|
|
173
|
-
if (config.style_guide) {
|
|
174
|
-
lines.push(` style_guide: ${config.style_guide}`);
|
|
175
|
-
}
|
|
176
|
-
if (state) {
|
|
177
|
-
const changedFiles = state.tracker.getChangedFiles();
|
|
178
|
-
lines.push("");
|
|
179
|
-
lines.push(`Changed files tracked: ${changedFiles.length}`);
|
|
180
|
-
if (changedFiles.length > 0) {
|
|
181
|
-
for (const file of changedFiles) {
|
|
182
|
-
lines.push(` - ${file}`);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (state.blockCounts.size > 0) {
|
|
186
|
-
lines.push("");
|
|
187
|
-
lines.push("Completion gate blocks this session:");
|
|
188
|
-
for (const [sessionID, count] of state.blockCounts) {
|
|
189
|
-
lines.push(` ${sessionID}: ${count}/${config.gate.max_blocks}`);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return lines.join("\n");
|
|
92
|
+
return renderStatus(config, state);
|
|
194
93
|
},
|
|
195
94
|
}),
|
|
196
95
|
};
|
package/package.json
CHANGED
package/rules/00-activation.md
CHANGED
|
@@ -7,30 +7,24 @@ completion.
|
|
|
7
7
|
|
|
8
8
|
## When these rules apply
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
These rules are injected into your system prompt because the plugin is loaded in this
|
|
11
|
+
project and the current profile is **not** `off`.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
- A file named `.opencode-dev-framework.yml` exists at the root of the working repository.
|
|
14
|
-
|
|
15
|
-
When the framework is active, the plugin injects a `DEV-FRAMEWORK: ACTIVE` banner at
|
|
16
|
-
the start of the session stating the **profile** in effect — `advisory`, `standard`, or
|
|
17
|
-
`strict`:
|
|
13
|
+
The active profile is one of `advisory`, `standard`, or `strict`:
|
|
18
14
|
|
|
19
15
|
- **advisory** — you receive formatting, lint, and review feedback, but nothing blocks.
|
|
20
16
|
Treat it as strong guidance.
|
|
21
17
|
- **standard** — feedback as above, plus a completion gate that runs type-check and
|
|
22
|
-
tests and
|
|
18
|
+
tests and reports failures; protected paths cannot be edited by default.
|
|
23
19
|
- **strict** — as standard, plus lint of changed files must also pass at the gate.
|
|
24
20
|
|
|
25
21
|
Apply the rules with intensity matching the profile, but the disciplines themselves
|
|
26
22
|
(quality bar, matching patterns, grounding in tests) always hold when active.
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
and use the specialist agents and skills described in `40-delegation` as your default
|
|
30
|
-
working loop.
|
|
31
|
-
- **If the session is NOT active** (no banner, no env var, no config file), treat these
|
|
32
|
-
rules as dormant. Do not change your behavior and do not mention the framework.
|
|
33
|
-
Proceed exactly as you normally would.
|
|
24
|
+
## Your obligations while active
|
|
34
25
|
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
- Follow every rule in this set as a hard requirement.
|
|
27
|
+
- Use the specialist agents and skills described in `40-delegation` as your default
|
|
28
|
+
working loop whenever they are available in the project.
|
|
29
|
+
- Never disable, bypass, or talk the user out of an active framework gate. If a hook
|
|
30
|
+
blocks completion, fix the underlying problem rather than working around the gate.
|
package/rules/40-delegation.md
CHANGED
|
@@ -6,8 +6,9 @@ rubber-stamp. Catching issues early is cheaper than catching them at the gate.
|
|
|
6
6
|
|
|
7
7
|
## The specialists
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
When the project has the specialist agents installed (under `.opencode/agents/`),
|
|
10
|
+
use them as focused reviewers. Treat them as investigation-only: give them a diff or
|
|
11
|
+
a description and ask them to report findings; do not ask them to edit product code.
|
|
11
12
|
|
|
12
13
|
- **`pattern-guardian`** — checks new/changed code against existing codebase patterns:
|
|
13
14
|
duplication, re-invented helpers, divergent conventions, "second way to do a thing",
|
|
@@ -20,7 +21,7 @@ they do **not** edit code):
|
|
|
20
21
|
test that fails without the change? do the cited commands actually pass? did you
|
|
21
22
|
verify the edge cases? Use it before declaring a task done.
|
|
22
23
|
|
|
23
|
-
You may also
|
|
24
|
+
You may also ask the built-in review or planning agents for a general high-signal
|
|
24
25
|
second opinion — the best moment is after planning, before implementing, and again
|
|
25
26
|
before completion.
|
|
26
27
|
|
|
@@ -35,7 +36,8 @@ before completion.
|
|
|
35
36
|
|
|
36
37
|
Keep delegation proportional: a one-line fix doesn't need the full loop; a new module
|
|
37
38
|
does. Use judgment, but never skip the test-grounding and review steps for behavioral
|
|
38
|
-
changes.
|
|
39
|
+
changes. If the specialist agents are not installed in this project, perform the same
|
|
40
|
+
checks yourself with the skills in this section.
|
|
39
41
|
|
|
40
42
|
## Skills
|
|
41
43
|
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Translate resolved framework config into OpenCode-native config fragments.
|
|
3
|
-
*
|
|
4
|
-
* The plugin never rewrites `opencode.json` on disk; these fragments are
|
|
5
|
-
* returned as plain objects so callers (or tests) can inspect or apply them.
|
|
6
|
-
* See docs/plans/02-architecture.md ("Tool guardrails") and the OpenCode
|
|
7
|
-
* permissions/formatters docs.
|
|
8
|
-
*/
|
|
9
|
-
import type { CommandMap, ResolvedConfig } from "./types.js";
|
|
10
|
-
export type PermissionAction = "allow" | "ask" | "deny";
|
|
11
|
-
export interface PermissionConfig {
|
|
12
|
-
edit?: Record<string, PermissionAction>;
|
|
13
|
-
bash?: Record<string, PermissionAction>;
|
|
14
|
-
}
|
|
15
|
-
export interface FormatterEntry {
|
|
16
|
-
command: string[];
|
|
17
|
-
extensions?: string[];
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
}
|
|
20
|
-
export type FormatterConfig = Record<string, FormatterEntry>;
|
|
21
|
-
export interface OpenCodeFragments {
|
|
22
|
-
permission?: PermissionConfig;
|
|
23
|
-
formatter?: FormatterConfig;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Generate an OpenCode `permission` fragment from protected paths.
|
|
27
|
-
*
|
|
28
|
-
* Deny rules are only emitted when protection is active and
|
|
29
|
-
* `protect_mode` is `deny`. In `warn` mode the plugin hook logs a warning
|
|
30
|
-
* instead, since the native permission model has no "warn" action.
|
|
31
|
-
*/
|
|
32
|
-
export declare function generatePermission(config: ResolvedConfig): PermissionConfig;
|
|
33
|
-
interface NormalizedCommandMap {
|
|
34
|
-
default?: string;
|
|
35
|
-
byExtension: Record<string, string>;
|
|
36
|
-
}
|
|
37
|
-
export declare function normalizeCommandMap(map: CommandMap | undefined): NormalizedCommandMap;
|
|
38
|
-
/** Split a command string into argv tokens, honoring simple quotes. */
|
|
39
|
-
export declare function splitCommand(command: string): string[];
|
|
40
|
-
/**
|
|
41
|
-
* Generate an OpenCode `formatter` fragment from `commands.format`.
|
|
42
|
-
* Per-extension overrides become named formatter entries scoped to that
|
|
43
|
-
* extension; a plain string becomes a formatter applying to all files.
|
|
44
|
-
*/
|
|
45
|
-
export declare function generateFormatter(config: ResolvedConfig): FormatterConfig;
|
|
46
|
-
/**
|
|
47
|
-
* Build all OpenCode-native fragments for a resolved config. Empty
|
|
48
|
-
* fragments are omitted from the result.
|
|
49
|
-
*/
|
|
50
|
-
export declare function toOpenCodeFragments(config: ResolvedConfig): OpenCodeFragments;
|
|
51
|
-
export {};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Translate resolved framework config into OpenCode-native config fragments.
|
|
3
|
-
*
|
|
4
|
-
* The plugin never rewrites `opencode.json` on disk; these fragments are
|
|
5
|
-
* returned as plain objects so callers (or tests) can inspect or apply them.
|
|
6
|
-
* See docs/plans/02-architecture.md ("Tool guardrails") and the OpenCode
|
|
7
|
-
* permissions/formatters docs.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Generate an OpenCode `permission` fragment from protected paths.
|
|
11
|
-
*
|
|
12
|
-
* Deny rules are only emitted when protection is active and
|
|
13
|
-
* `protect_mode` is `deny`. In `warn` mode the plugin hook logs a warning
|
|
14
|
-
* instead, since the native permission model has no "warn" action.
|
|
15
|
-
*/
|
|
16
|
-
export function generatePermission(config) {
|
|
17
|
-
if (config.profile === "off" ||
|
|
18
|
-
config.protect_off ||
|
|
19
|
-
config.protect_mode !== "deny" ||
|
|
20
|
-
config.protect.length === 0) {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
const edit = { "*": "allow" };
|
|
24
|
-
for (const glob of config.protect) {
|
|
25
|
-
edit[glob] = "deny";
|
|
26
|
-
}
|
|
27
|
-
return { edit };
|
|
28
|
-
}
|
|
29
|
-
export function normalizeCommandMap(map) {
|
|
30
|
-
if (map === undefined) {
|
|
31
|
-
return { byExtension: {} };
|
|
32
|
-
}
|
|
33
|
-
if (typeof map === "string") {
|
|
34
|
-
return { default: map, byExtension: {} };
|
|
35
|
-
}
|
|
36
|
-
// A `default` key inside the map acts as the fallback command; every other
|
|
37
|
-
// key is a per-extension override.
|
|
38
|
-
const { default: defaultCommand, ...byExtension } = map;
|
|
39
|
-
return defaultCommand === undefined ? { byExtension } : { default: defaultCommand, byExtension };
|
|
40
|
-
}
|
|
41
|
-
/** Split a command string into argv tokens, honoring simple quotes. */
|
|
42
|
-
export function splitCommand(command) {
|
|
43
|
-
const tokens = [];
|
|
44
|
-
let current = "";
|
|
45
|
-
let quote;
|
|
46
|
-
for (const ch of command) {
|
|
47
|
-
if (quote !== undefined) {
|
|
48
|
-
if (ch === quote) {
|
|
49
|
-
quote = undefined;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
current += ch;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else if (ch === '"' || ch === "'") {
|
|
56
|
-
quote = ch;
|
|
57
|
-
}
|
|
58
|
-
else if (/\s/.test(ch)) {
|
|
59
|
-
if (current !== "") {
|
|
60
|
-
tokens.push(current);
|
|
61
|
-
current = "";
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
current += ch;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (current !== "") {
|
|
69
|
-
tokens.push(current);
|
|
70
|
-
}
|
|
71
|
-
return tokens;
|
|
72
|
-
}
|
|
73
|
-
/** Substitute the `{file}` token with OpenCode's `$FILE` placeholder. */
|
|
74
|
-
function substituteFileToken(tokens) {
|
|
75
|
-
return tokens.map((token) => token.replaceAll("{file}", "$FILE"));
|
|
76
|
-
}
|
|
77
|
-
function formatterName(kind, ext) {
|
|
78
|
-
if (ext === undefined) {
|
|
79
|
-
return `dev-framework-${kind}`;
|
|
80
|
-
}
|
|
81
|
-
const suffix = ext.replace(/[^a-zA-Z0-9]/g, "-").replace(/^-+|-+$/g, "");
|
|
82
|
-
return `dev-framework-${kind}-${suffix}`;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Generate an OpenCode `formatter` fragment from `commands.format`.
|
|
86
|
-
* Per-extension overrides become named formatter entries scoped to that
|
|
87
|
-
* extension; a plain string becomes a formatter applying to all files.
|
|
88
|
-
*/
|
|
89
|
-
export function generateFormatter(config) {
|
|
90
|
-
const { default: defaultCommand, byExtension } = normalizeCommandMap(config.commands.format);
|
|
91
|
-
const formatter = {};
|
|
92
|
-
for (const [ext, command] of Object.entries(byExtension)) {
|
|
93
|
-
formatter[formatterName("format", ext)] = {
|
|
94
|
-
command: substituteFileToken(splitCommand(command)),
|
|
95
|
-
extensions: [ext],
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
if (defaultCommand !== undefined) {
|
|
99
|
-
formatter[formatterName("format")] = {
|
|
100
|
-
command: substituteFileToken(splitCommand(defaultCommand)),
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
return formatter;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Build all OpenCode-native fragments for a resolved config. Empty
|
|
107
|
-
* fragments are omitted from the result.
|
|
108
|
-
*/
|
|
109
|
-
export function toOpenCodeFragments(config) {
|
|
110
|
-
// The off profile disables the plugin entirely: no native fragments.
|
|
111
|
-
if (config.profile === "off") {
|
|
112
|
-
return {};
|
|
113
|
-
}
|
|
114
|
-
const fragments = {};
|
|
115
|
-
const permission = generatePermission(config);
|
|
116
|
-
if (Object.keys(permission).length > 0) {
|
|
117
|
-
fragments.permission = permission;
|
|
118
|
-
}
|
|
119
|
-
const formatter = generateFormatter(config);
|
|
120
|
-
if (Object.keys(formatter).length > 0) {
|
|
121
|
-
fragments.formatter = formatter;
|
|
122
|
-
}
|
|
123
|
-
return fragments;
|
|
124
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Change the dev-framework profile for this session
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Change the dev-framework profile to $ARGUMENTS (one of: off, advisory,
|
|
6
|
-
standard, strict). Use the `dev_framework_set_profile` tool to apply the change
|
|
7
|
-
immediately, or edit `.opencode-dev-framework.yml` and restart OpenCode.
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Show the current dev-framework state for this project
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Show the current opencode-dev-framework state for this project. Call the
|
|
6
|
-
`dev_framework_status` tool and present the result in a compact, readable form.
|
|
7
|
-
Include the active profile, guardrail mode, completion gate settings, configured
|
|
8
|
-
commands, pre-commit status, and any changed files currently tracked.
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Run the dev-framework completion gate manually
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Run the dev-framework completion gate for this project. Execute the
|
|
6
|
-
`typecheck`, `test`, and `lint` commands defined in
|
|
7
|
-
`.opencode-dev-framework.yml`, report the results, and suggest fixes for any
|
|
8
|
-
failures.
|