opencode-dev-framework 1.9.4 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -33
- package/bin/df +94 -4
- package/cordis.patch.yml +17 -0
- package/dist/adapters/dsh/extract.d.ts +47 -0
- package/dist/adapters/dsh/extract.js +62 -0
- package/dist/adapters/dsh/index.d.ts +332 -0
- package/dist/adapters/dsh/index.js +1643 -0
- package/dist/adapters/opencode/index.d.ts +30 -0
- package/dist/{index.js → adapters/opencode/index.js} +138 -251
- package/dist/{block-store.d.ts → core/block-store.d.ts} +10 -3
- package/dist/{commands.js → core/commands.js} +4 -2
- package/dist/{config.d.ts → core/config.d.ts} +16 -4
- package/dist/{config.js → core/config.js} +102 -10
- package/dist/{format-status.d.ts → core/format-status.d.ts} +13 -2
- package/dist/{format-status.js → core/format-status.js} +30 -7
- package/dist/{gate.d.ts → core/gate.d.ts} +9 -1
- package/dist/{gate.js → core/gate.js} +14 -2
- package/dist/{goal.d.ts → core/goal.d.ts} +4 -3
- package/dist/{goal.js → core/goal.js} +4 -3
- package/dist/{harness.d.ts → core/harness.d.ts} +10 -5
- package/dist/{harness.js → core/harness.js} +119 -32
- package/dist/{init.d.ts → core/init.d.ts} +18 -1
- package/dist/{init.js → core/init.js} +33 -8
- package/dist/core/install-dsh.d.ts +67 -0
- package/dist/core/install-dsh.js +235 -0
- package/dist/{installer.d.ts → core/installer.d.ts} +32 -2
- package/dist/{installer.js → core/installer.js} +129 -12
- package/dist/{lint.d.ts → core/lint.d.ts} +43 -2
- package/dist/{lint.js → core/lint.js} +89 -2
- package/dist/{logger.js → core/logger.js} +30 -1
- package/dist/core/paths.d.ts +35 -0
- package/dist/core/paths.js +41 -0
- package/dist/{protect.d.ts → core/protect.d.ts} +18 -4
- package/dist/{protect.js → core/protect.js} +85 -34
- package/dist/{registry.d.ts → core/registry.d.ts} +36 -15
- package/dist/{registry.js → core/registry.js} +66 -52
- package/dist/{review.js → core/review.js} +18 -6
- package/dist/{rules.d.ts → core/rules.d.ts} +3 -2
- package/dist/{rules.js → core/rules.js} +21 -5
- package/dist/core/run-hooks.d.ts +138 -0
- package/dist/core/run-hooks.js +196 -0
- package/dist/{runtime-status.d.ts → core/runtime-status.d.ts} +5 -4
- package/dist/{runtime-status.js → core/runtime-status.js} +29 -17
- package/dist/{types.d.ts → core/types.d.ts} +17 -0
- package/dist/{update.d.ts → core/update.d.ts} +12 -4
- package/dist/{update.js → core/update.js} +28 -12
- package/dist/{weakening.js → core/weakening.js} +2 -1
- package/package.json +16 -6
- package/rules/40-delegation.md +13 -2
- package/templates/.opencode/agents/style-enforcer.md +1 -1
- package/templates/.opencode/agents/test-grounder.md +1 -1
- package/templates/.opencode/skills/ground-in-tests/SKILL.md +1 -1
- package/templates/.opencode/skills/peer-review/SKILL.md +6 -1
- package/templates/.opencode/skills/project-config/SKILL.md +2 -2
- package/tui.tsx +6 -6
- package/dist/index.d.ts +0 -101
- /package/dist/{block-store.js → core/block-store.js} +0 -0
- /package/dist/{command-utils.d.ts → core/command-utils.d.ts} +0 -0
- /package/dist/{command-utils.js → core/command-utils.js} +0 -0
- /package/dist/{commands.d.ts → core/commands.d.ts} +0 -0
- /package/dist/{detect.d.ts → core/detect.d.ts} +0 -0
- /package/dist/{detect.js → core/detect.js} +0 -0
- /package/dist/{host.d.ts → core/host.d.ts} +0 -0
- /package/dist/{host.js → core/host.js} +0 -0
- /package/dist/{logger.d.ts → core/logger.d.ts} +0 -0
- /package/dist/{review.d.ts → core/review.d.ts} +0 -0
- /package/dist/{roster.d.ts → core/roster.d.ts} +0 -0
- /package/dist/{roster.js → core/roster.js} +0 -0
- /package/dist/{types.js → core/types.js} +0 -0
- /package/dist/{weakening.d.ts → core/weakening.d.ts} +0 -0
- /package/templates/{.opencode/opencode-dev-framework → .dev-framework}/rules/.gitkeep +0 -0
package/README.md
CHANGED
|
@@ -1,26 +1,43 @@
|
|
|
1
1
|
# opencode-dev-framework
|
|
2
2
|
|
|
3
|
-
AI agents
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
AI agents can say they're done without proving it. This plugin replaces
|
|
4
|
+
assertion with evidence: guardrails, per-edit formatting and lint feedback,
|
|
5
|
+
a completion gate that runs your real checks, and verified goals that require
|
|
6
|
+
a tool-result PASS on the final tree. Exit codes don't negotiate.
|
|
7
|
+
|
|
8
|
+
One shared enforcement core powers native adapters for
|
|
9
|
+
[OpenCode](https://opencode.ai) and [DSH](https://www.deepseek.com/en/harness/)
|
|
10
|
+
(DeepSeek Harness, via Cordis), with
|
|
11
|
+
the same config, profiles, rules, and gates on both.
|
|
12
|
+
|
|
13
|
+
Inspired by
|
|
13
14
|
[anticomputer/dev-framework](https://github.com/anticomputer/dev-framework),
|
|
14
|
-
|
|
15
|
+
which supports Copilot CLI, Claude Code, and Codex CLI; this is an independent
|
|
16
|
+
implementation. DSH guide: [`docs/user/dsh.md`](docs/user/dsh.md).
|
|
15
17
|
|
|
16
18
|
## Quickstart
|
|
17
19
|
|
|
18
|
-
Five minutes from zero to your first gated session
|
|
20
|
+
Five minutes from zero to your first gated session.
|
|
21
|
+
|
|
22
|
+
### 1. Install the plugin
|
|
23
|
+
|
|
24
|
+
**On OpenCode:**
|
|
19
25
|
|
|
20
26
|
```bash
|
|
21
27
|
opencode plugin add opencode-dev-framework
|
|
22
28
|
```
|
|
23
29
|
|
|
30
|
+
**On DSH:**
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
dsh plugin --profile <name> add opencode-dev-framework
|
|
34
|
+
df install-dsh --profile <name> # preset seam + verification
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Full DSH reference: [`docs/user/dsh.md`](docs/user/dsh.md).
|
|
38
|
+
|
|
39
|
+
### 2. Init your project (same on both harnesses)
|
|
40
|
+
|
|
24
41
|
In any project, run:
|
|
25
42
|
|
|
26
43
|
```text
|
|
@@ -35,44 +52,102 @@ a config + `hardening.md` draft for your review. Budget ~5 minutes,
|
|
|
35
52
|
review-only at the end; imperfections assumed, manual always possible.
|
|
36
53
|
|
|
37
54
|
Prefer a shell? Same thing non-interactively — for CI, dotfiles, and
|
|
38
|
-
scripted runs
|
|
55
|
+
scripted runs (add `--dsh` on DSH so the host-visible skill mirror is
|
|
56
|
+
scaffolded too):
|
|
39
57
|
|
|
40
58
|
```bash
|
|
41
|
-
npx df init
|
|
59
|
+
npx df init [--dsh]
|
|
42
60
|
```
|
|
43
61
|
|
|
44
62
|
Conflicts need `--overwrite-existing` or `--skip-existing` — everything
|
|
45
63
|
else is under `npx df init --help`.
|
|
46
64
|
|
|
65
|
+
On DSH, run `dsh` from the project root (or export `ODF_WORKDIR`), and
|
|
66
|
+
accept template drift via `df-update` if the session reports any.
|
|
67
|
+
|
|
47
68
|
Then ask the agent for a small edit. You will see the plugin working: the
|
|
48
69
|
edit is checked against guardrails before it lands, your linter runs on the
|
|
49
70
|
edited file, and when the session goes idle the completion gate runs your
|
|
50
71
|
typecheck/tests. `/df-status` shows the live state at any time. Start with
|
|
51
72
|
`profile: advisory` if you want to observe before enforcing.
|
|
52
73
|
|
|
74
|
+
## Local development
|
|
75
|
+
|
|
76
|
+
From a checkout — the contributor loop. Build once, then wire the profile
|
|
77
|
+
directly at the built file (no registry needed):
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm run build
|
|
81
|
+
df install-dsh --profile <name> --dist /path/to/opencode-dev-framework/dist/adapters/dsh/index.js
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Rebuild after every source change; rerun `df install-dsh` any time
|
|
85
|
+
(it is idempotent outside its managed block). The full contributor
|
|
86
|
+
contract — validation commands, commit policy, never-push rule — is
|
|
87
|
+
[`AGENTS.md`](AGENTS.md).
|
|
88
|
+
|
|
89
|
+
## Harness differences
|
|
90
|
+
|
|
91
|
+
Same core, same config, same profiles — different wiring where the hosts
|
|
92
|
+
differ. Neither harness is the "real" one; each is stronger somewhere:
|
|
93
|
+
|
|
94
|
+
| Area | OpenCode | DSH |
|
|
95
|
+
| ---- | -------- | --- |
|
|
96
|
+
| Completion gate | Synthetic continuation at the idle boundary (re-prompt round-trip) | **Blocks termination pre-terminal; failure work continues in the same turn** |
|
|
97
|
+
| Per-edit lint | Logged against the landed edit | **Fails the tool call (`block`) — agent retries same turn** |
|
|
98
|
+
| Guard `warn` | Logged (advisory never blocks) | Logged, or **prompts the human as `ask`** when the `approval` seam is injected |
|
|
99
|
+
| Redirect targets (`a > file`) | Not guard-checked | **Guard-checked** (wider than OpenCode) |
|
|
100
|
+
| denial identity | Reason text | Reason text + structured `{name, code}` |
|
|
101
|
+
| Skills | `.opencode/skills` (native) | `.dsh/skills` (installed by `df-init`, kept current by `df-update`) |
|
|
102
|
+
| 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 |
|
|
103
|
+
| Goals | `/df-goal` wraps native `/goal` | `df-goal` creates the host goal with the same verification contract |
|
|
104
|
+
| Install | One command (`opencode plugin add`) | `dsh plugin add` + `df install-dsh` (bundle auto-wires post-release) |
|
|
105
|
+
| Review UI | Instant TUI modals, never feed the LLM | Host commands returning text |
|
|
106
|
+
|
|
107
|
+
Bold marks where DSH currently enforces harder — the host exposes
|
|
108
|
+
pre-terminal hooks, tool-call blocking, and human approval, so the
|
|
109
|
+
same verdict bites earlier and louder there. OpenCode keeps the edge
|
|
110
|
+
in install simplicity and instant review UI; both run the identical
|
|
111
|
+
gate contract (typecheck, tests, acceptance, review artifact,
|
|
112
|
+
`max_blocks` budgeting).
|
|
113
|
+
|
|
114
|
+
Identical on both: pre-execute deny hardness, pre-flight ordering and
|
|
115
|
+
semantics, block budgeting, `protect_off` scope, and all eight
|
|
116
|
+
`df-*`/`dev_framework_*` command and tool names. Details:
|
|
117
|
+
[`docs/user/enforcement.md`](docs/user/enforcement.md) (OpenCode),
|
|
118
|
+
[`docs/user/dsh.md`](docs/user/dsh.md) (DSH).
|
|
119
|
+
|
|
53
120
|
## What it does
|
|
54
121
|
|
|
55
122
|
- **Constitution injection.** Adds a project quality bar to the system prompt
|
|
56
123
|
at session start (bundled default, overridable per project).
|
|
57
124
|
- **Guardrails.** Blocks or warns on protected paths (`.env`, vendored
|
|
58
125
|
code, your own globs) and dangerous shell commands (`git push`, `rm -rf`).
|
|
59
|
-
- **Per-edit lint.** Runs your linter on each edited file
|
|
126
|
+
- **Per-edit lint.** Runs your linter on each edited file. On OpenCode
|
|
127
|
+
the result is logged against the landed edit; on DSH a finding fails
|
|
128
|
+
the tool call so the agent retries clean in the same turn.
|
|
60
129
|
- **Completion gate.** At the would-go-idle boundary, runs typecheck, tests,
|
|
61
130
|
acceptance checks, and (optionally) lint on changed files — plus a required
|
|
62
131
|
substantive peer-review artifact in `standard`/`strict` (length floors, no
|
|
63
|
-
template checkboxes).
|
|
64
|
-
|
|
132
|
+
template checkboxes, written after the latest session edit). On OpenCode, failures steer the session back via a
|
|
133
|
+
synthetic continuation, bounded by `gate.max_blocks` (fewer when
|
|
65
134
|
the failure repeats with no new edits — the gate stands down early on
|
|
66
|
-
zero progress).
|
|
135
|
+
zero progress). On DSH the same verdict runs pre-terminal in the same
|
|
136
|
+
turn — no re-prompt round-trip.
|
|
67
137
|
- **Verified goals (`/df-goal`).** Wraps a task in native `/goal` with a
|
|
68
138
|
verification contract the reviewer weighs as evidence.
|
|
69
139
|
- **Pre-flight gate (optional).** Denies edits until the agent records
|
|
70
140
|
required upfront research.
|
|
71
141
|
- **Custom tools + CLI.** `dev_framework_*` tools for in-agent use;
|
|
72
|
-
`df init / profile / status / version
|
|
142
|
+
`df init [--dsh] / profile / status / version / install-dsh --profile <name>`
|
|
143
|
+
from the shell (children may not invoke gate tools — deny + redirect).
|
|
73
144
|
|
|
74
145
|
## Minimal configuration
|
|
75
146
|
|
|
147
|
+
Create `.dev-framework.yml` in your project root (the legacy
|
|
148
|
+
`.opencode-dev-framework.yml` name is still read when no neutral-named
|
|
149
|
+
file exists):
|
|
150
|
+
|
|
76
151
|
```yaml
|
|
77
152
|
profile: standard
|
|
78
153
|
|
|
@@ -89,7 +164,10 @@ starters: [`examples/go-service/`](examples/go-service/).
|
|
|
89
164
|
|
|
90
165
|
Every session runs the same loop — constitution, guardrails, lint, gate —
|
|
91
166
|
whether or not it starts under `/df-goal`. A goal just wraps that loop in
|
|
92
|
-
native verification
|
|
167
|
+
native verification. The diagram below shows the OpenCode wiring (idle
|
|
168
|
+
synthetic continuation); on DSH the same verdict bites earlier — the
|
|
169
|
+
pre-terminal completion block, same-turn lint `block`s, and dispatched
|
|
170
|
+
reviewers above all run inside the turn instead of round-tripping through it:
|
|
93
171
|
|
|
94
172
|
```text
|
|
95
173
|
user prompt
|
|
@@ -159,24 +237,50 @@ How each layer is enforced, and what it honestly cannot do:
|
|
|
159
237
|
| `/df-goal <objective>` | Server-side command: starts a **verified** native goal (requires native `/goal`, a blocking profile, and at least one real check). |
|
|
160
238
|
|
|
161
239
|
The TUI commands open instantly and never feed the LLM; `/df-init`,
|
|
162
|
-
`/df-update`, and `/df-goal` are server-side and drive the session.
|
|
240
|
+
`/df-update`, and `/df-goal` are server-side and drive the session. Same
|
|
241
|
+
eight names on DSH, where they run as host commands returning text instead
|
|
242
|
+
of modals. Full reference:
|
|
163
243
|
[`docs/user/commands.md`](docs/user/commands.md).
|
|
164
244
|
|
|
165
245
|
## Limitations (short version)
|
|
166
246
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
-
|
|
175
|
-
-
|
|
176
|
-
-
|
|
177
|
-
reimplement them.
|
|
247
|
+
### Both harnesses
|
|
248
|
+
|
|
249
|
+
- Completion enforcement is bounded by `gate.max_blocks` (and stands down
|
|
250
|
+
earlier after repeated failures with no new edits). Stand-down is loud,
|
|
251
|
+
and you can always close the session; this is not an unlimited trap.
|
|
252
|
+
- **Pre-flight and guardrail denials are pre-edit hard blocks**, distinct
|
|
253
|
+
from the bounded completion mechanisms below.
|
|
254
|
+
- A cached pass never survives a restart — after a restart the gate
|
|
255
|
+
always re-verifies the final tree from scratch.
|
|
256
|
+
- Formatting and linting stay with your project tooling — the framework
|
|
257
|
+
does not reimplement them.
|
|
178
258
|
|
|
179
|
-
|
|
259
|
+
### OpenCode
|
|
260
|
+
|
|
261
|
+
- A failed completion gate admits a synthetic continuation at the idle
|
|
262
|
+
boundary. A genuine pre-stop veto was proposed upstream
|
|
263
|
+
([`anomalyco/opencode#54487`](https://github.com/anomalyco/opencode/pull/54487),
|
|
264
|
+
closed unmerged) — restoration is tracked in `docs/plans/08-notes.md`
|
|
265
|
+
if the hook ever lands.
|
|
266
|
+
- Guardrails add to OpenCode permissions; they never replace them.
|
|
267
|
+
Formatting is OpenCode core's job, not the plugin's.
|
|
268
|
+
|
|
269
|
+
### DSH
|
|
270
|
+
|
|
271
|
+
- In `standard`/`strict`, a failed completion gate blocks termination
|
|
272
|
+
pre-terminal and enqueues required same-turn work until pass or stand-down.
|
|
273
|
+
- After a restart, all prior gate state is unknown (block budget
|
|
274
|
+
included) — the gate re-verifies from scratch. `df-status` reports
|
|
275
|
+
continuity per session (`clean`, `resumed after interruption`, or
|
|
276
|
+
`unknown`).
|
|
277
|
+
- Human approval prompts, reviewer dispatch, and the read-only reviewer
|
|
278
|
+
preset depend on services provided by the DSH profile. Missing optional
|
|
279
|
+
services disable only their enhancement; `df-status` reports the seams.
|
|
280
|
+
`df install-dsh` handles the profile-dependent preset wiring.
|
|
281
|
+
|
|
282
|
+
Full story: [`docs/user/enforcement.md`](docs/user/enforcement.md)
|
|
283
|
+
(OpenCode), [`docs/user/dsh.md`](docs/user/dsh.md) (DSH).
|
|
180
284
|
|
|
181
285
|
## Troubleshooting
|
|
182
286
|
|
package/bin/df
CHANGED
|
@@ -7,17 +7,21 @@ import { dirname, join } from "node:path";
|
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import {
|
|
9
9
|
buildWizardBrief,
|
|
10
|
+
DSH_SKILL_ROOTS,
|
|
10
11
|
formatTrialRun,
|
|
11
12
|
formatWizardBrief,
|
|
12
13
|
installTemplates,
|
|
14
|
+
mirrorSkillsToDsh,
|
|
13
15
|
resolveTargetDir,
|
|
14
16
|
setProfileInFile,
|
|
15
17
|
statusTemplates,
|
|
16
18
|
trialRunDetectedCommands,
|
|
17
19
|
writeDetectedConfig,
|
|
18
|
-
} from "../dist/installer.js";
|
|
19
|
-
import { detectProject } from "../dist/detect.js";
|
|
20
|
-
import {
|
|
20
|
+
} from "../dist/core/installer.js";
|
|
21
|
+
import { detectProject } from "../dist/core/detect.js";
|
|
22
|
+
import { existingConfigPath } from "../dist/core/config.js";
|
|
23
|
+
import { installDshProfile } from "../dist/core/install-dsh.js";
|
|
24
|
+
import { runCommand } from "../dist/core/host.js";
|
|
21
25
|
|
|
22
26
|
async function getVersion() {
|
|
23
27
|
const packagePath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
@@ -32,6 +36,8 @@ Usage:
|
|
|
32
36
|
df init [dir] Scaffold templates into a project (default: cwd)
|
|
33
37
|
df profile <name> [dir] Set profile to off, advisory, standard, or strict
|
|
34
38
|
df status [dir] Show which template files are missing/present/different
|
|
39
|
+
df install-dsh --profile <name> Wire the adapter into a DSH profile
|
|
40
|
+
(managed patch block; npm-first, --dist for local)
|
|
35
41
|
df version Print the plugin version
|
|
36
42
|
df help Show this help
|
|
37
43
|
|
|
@@ -41,6 +47,8 @@ Usage:
|
|
|
41
47
|
|
|
42
48
|
Options:
|
|
43
49
|
--wizard Print the wizard brief after init (agent-led handoff)
|
|
50
|
+
--dsh Also mirror skills into .dsh/skills so the DSH host
|
|
51
|
+
skill tool catalogs them (same skip/overwrite rules)
|
|
44
52
|
--overwrite-existing Overwrite files that already exist (non-interactive)
|
|
45
53
|
--skip-existing Skip files that already exist (non-interactive)
|
|
46
54
|
`);
|
|
@@ -53,6 +61,66 @@ function formatList(label, files) {
|
|
|
53
61
|
return [`${label}:`, ...files.map((file) => ` - ${file}`)];
|
|
54
62
|
}
|
|
55
63
|
|
|
64
|
+
function flagValue(args, flag) {
|
|
65
|
+
const index = args.indexOf(flag);
|
|
66
|
+
if (index === -1 || index + 1 >= args.length) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const value = args[index + 1];
|
|
70
|
+
return value.startsWith("--") ? undefined : value;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function runInstallDsh(args) {
|
|
74
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
75
|
+
console.log(`df install-dsh --profile <name> [--dist <file> | --package <spec>]
|
|
76
|
+
[--with-presets | --no-presets] [--force] [--dry-run]
|
|
77
|
+
[--dsh-home <dir>] [--dsh-bin <bin>]
|
|
78
|
+
|
|
79
|
+
Wire the ODF adapter into a DSH profile with a managed patch block
|
|
80
|
+
(idempotent; user content outside the block is preserved). Defaults to
|
|
81
|
+
the npm package spec; --dist points at a local build instead.`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const profile = flagValue(args, "--profile");
|
|
85
|
+
if (!profile) {
|
|
86
|
+
console.error("df install-dsh: --profile <name> is required");
|
|
87
|
+
process.exitCode = 1;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const distFile = flagValue(args, "--dist");
|
|
91
|
+
const packageSpec = flagValue(args, "--package");
|
|
92
|
+
const withPresets = args.includes("--with-presets")
|
|
93
|
+
? true
|
|
94
|
+
: args.includes("--no-presets")
|
|
95
|
+
? false
|
|
96
|
+
: "auto";
|
|
97
|
+
try {
|
|
98
|
+
const result = await installDshProfile({
|
|
99
|
+
profile,
|
|
100
|
+
dshHome: flagValue(args, "--dsh-home"),
|
|
101
|
+
dshBin: flagValue(args, "--dsh-bin") ?? "dsh",
|
|
102
|
+
...(distFile !== undefined ? { distFile } : {}),
|
|
103
|
+
...(packageSpec !== undefined ? { packageSpec } : {}),
|
|
104
|
+
withPresets,
|
|
105
|
+
force: args.includes("--force"),
|
|
106
|
+
dryRun: args.includes("--dry-run"),
|
|
107
|
+
});
|
|
108
|
+
console.log(`DSH profile "${profile}": ${result.patchFile}`);
|
|
109
|
+
console.log(` entry: ${result.entryName}`);
|
|
110
|
+
console.log(` seams: ${result.seams.join(", ")}`);
|
|
111
|
+
console.log(` ${result.createdPatchFile ? "patch file created" : result.changed ? "managed block written" : "already current (no changes)"}`);
|
|
112
|
+
for (const warning of result.warnings) {
|
|
113
|
+
console.log(` warning: ${warning}`);
|
|
114
|
+
}
|
|
115
|
+
if (args.includes("--dry-run")) {
|
|
116
|
+
console.log(" dry run: nothing written");
|
|
117
|
+
}
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error(`df install-dsh failed: ${error instanceof Error ? error.message : error}`);
|
|
120
|
+
process.exitCode = 1;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
56
124
|
async function main() {
|
|
57
125
|
const args = process.argv.slice(2);
|
|
58
126
|
const command = args[0];
|
|
@@ -80,12 +148,20 @@ async function main() {
|
|
|
80
148
|
process.exitCode = 1;
|
|
81
149
|
return;
|
|
82
150
|
}
|
|
83
|
-
|
|
151
|
+
// New file only when no config exists under any supported name; an
|
|
152
|
+
// established deployment is edited in place, never shadowed.
|
|
153
|
+
const fresh = join(profileDir, ".dev-framework.yml");
|
|
154
|
+
const configPath = existingConfigPath(profileDir) ?? fresh;
|
|
84
155
|
await setProfileInFile(configPath, profile);
|
|
85
156
|
console.log(`Profile set to "${profile}" in ${configPath}`);
|
|
86
157
|
return;
|
|
87
158
|
}
|
|
88
159
|
|
|
160
|
+
if (command === "install-dsh") {
|
|
161
|
+
await runInstallDsh(args.slice(1));
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
89
165
|
if (command !== "init" && command !== "status") {
|
|
90
166
|
console.error(`Unknown command: ${command}`);
|
|
91
167
|
printHelp();
|
|
@@ -133,6 +209,20 @@ async function main() {
|
|
|
133
209
|
console.log(line);
|
|
134
210
|
}
|
|
135
211
|
console.log(`\nConfig: ${configResult.action}`);
|
|
212
|
+
if (flags.has("--dsh")) {
|
|
213
|
+
const mirror = await mirrorSkillsToDsh(targetDir, DSH_SKILL_ROOTS[0], {
|
|
214
|
+
overwriteExisting: flags.has("--overwrite-existing"),
|
|
215
|
+
skipExisting: flags.has("--skip-existing"),
|
|
216
|
+
});
|
|
217
|
+
console.log("\nDSH skill mirror (.dsh/skills):");
|
|
218
|
+
for (const line of [
|
|
219
|
+
...formatList("Created", mirror.created),
|
|
220
|
+
...formatList("Overwritten", mirror.overwritten),
|
|
221
|
+
...formatList("Skipped", mirror.skipped),
|
|
222
|
+
]) {
|
|
223
|
+
console.log(line);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
136
226
|
if (flags.has("--wizard")) {
|
|
137
227
|
try {
|
|
138
228
|
const brief = await buildWizardBrief(targetDir, runCommand);
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# opencode-dev-framework — DSH bundle layer.
|
|
2
|
+
# Auto-applied when the package is installed (`dsh plugin --profile
|
|
3
|
+
# <name> add opencode-dev-framework`). Base seams only: every entry
|
|
4
|
+
# here must resolve on EVERY profile (headless, tui, web), because a
|
|
5
|
+
# missing injected service pends the whole plugin. The read-only
|
|
6
|
+
# reviewer preset (`agentPresets`) is profile-dependent and therefore
|
|
7
|
+
# NOT here — `df install-dsh` adds it as a user-layer override where
|
|
8
|
+
# the registry exists.
|
|
9
|
+
- insert:
|
|
10
|
+
- id: odf-gates
|
|
11
|
+
name: opencode-dev-framework/dsh
|
|
12
|
+
- id: odf-gates
|
|
13
|
+
inject:
|
|
14
|
+
- tools
|
|
15
|
+
- goals
|
|
16
|
+
- approval
|
|
17
|
+
- subagents
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSH envelope extraction (pure, host-agnostic).
|
|
3
|
+
*
|
|
4
|
+
* DSH tool names and arg shapes differ from OpenCode's (`file_path`
|
|
5
|
+
* snake_case, `apply_patch` patch-text input, `bash`/`shell` with
|
|
6
|
+
* `command`), so this module normalizes a DSH `ToolExecution` into the
|
|
7
|
+
* plain strings core guards consume. Verdicts and reason text always come
|
|
8
|
+
* from core (`decideFileGuard`/`decideShellGuard`) — never built here.
|
|
9
|
+
*/
|
|
10
|
+
/** Host session header parentage (structural — no DSH imports).
|
|
11
|
+
* Shared by `DshExec["agent"]` and the adapter's `DshAgent` so the two
|
|
12
|
+
* never fork: one spelling for the header both sides read. */
|
|
13
|
+
export interface DshSessionHeader {
|
|
14
|
+
readonly origin?: unknown;
|
|
15
|
+
readonly parentSession?: unknown;
|
|
16
|
+
}
|
|
17
|
+
/** Minimal DSH tool-execution shape (structural — no DSH imports). */
|
|
18
|
+
export interface DshExec {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly arguments?: unknown;
|
|
21
|
+
/**
|
|
22
|
+
* Executing agent, when the host attaches it (carries session
|
|
23
|
+
* parentage for the child-session guard; structural so no host
|
|
24
|
+
* import is needed — compatible with the adapter's `DshAgent`).
|
|
25
|
+
*/
|
|
26
|
+
readonly agent?: {
|
|
27
|
+
readonly session?: {
|
|
28
|
+
readonly header?: DshSessionHeader;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* File paths a DSH tool call intends to mutate.
|
|
34
|
+
*
|
|
35
|
+
* - `write`/`edit`: `file_path` (DSH snake_case) plus the core camelCase
|
|
36
|
+
* keys, via core `extractFilePath`.
|
|
37
|
+
* - `apply_patch`: `*** Add|Update|Move to|Delete File: path` headers
|
|
38
|
+
* (DSH patch-text format, relative to the session working directory).
|
|
39
|
+
* Any other envelope yields `[]` — callers warn loudly in that case
|
|
40
|
+
* rather than silently standing down.
|
|
41
|
+
* - Shell tools yield `[]` here; their write targets come from
|
|
42
|
+
* `extractRedirectTargets` on the command string (core), wired by the
|
|
43
|
+
* adapter's post-execute path union.
|
|
44
|
+
*/
|
|
45
|
+
export declare function extractDshPaths(exec: DshExec): string[];
|
|
46
|
+
/** Shell command string for `bash`/`shell` tools, if present. */
|
|
47
|
+
export declare function extractDshCommand(exec: DshExec): string | undefined;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSH envelope extraction (pure, host-agnostic).
|
|
3
|
+
*
|
|
4
|
+
* DSH tool names and arg shapes differ from OpenCode's (`file_path`
|
|
5
|
+
* snake_case, `apply_patch` patch-text input, `bash`/`shell` with
|
|
6
|
+
* `command`), so this module normalizes a DSH `ToolExecution` into the
|
|
7
|
+
* plain strings core guards consume. Verdicts and reason text always come
|
|
8
|
+
* from core (`decideFileGuard`/`decideShellGuard`) — never built here.
|
|
9
|
+
*/
|
|
10
|
+
import { extractCommand, extractFilePath } from "../../core/protect.js";
|
|
11
|
+
/**
|
|
12
|
+
* File paths a DSH tool call intends to mutate.
|
|
13
|
+
*
|
|
14
|
+
* - `write`/`edit`: `file_path` (DSH snake_case) plus the core camelCase
|
|
15
|
+
* keys, via core `extractFilePath`.
|
|
16
|
+
* - `apply_patch`: `*** Add|Update|Move to|Delete File: path` headers
|
|
17
|
+
* (DSH patch-text format, relative to the session working directory).
|
|
18
|
+
* Any other envelope yields `[]` — callers warn loudly in that case
|
|
19
|
+
* rather than silently standing down.
|
|
20
|
+
* - Shell tools yield `[]` here; their write targets come from
|
|
21
|
+
* `extractRedirectTargets` on the command string (core), wired by the
|
|
22
|
+
* adapter's post-execute path union.
|
|
23
|
+
*/
|
|
24
|
+
export function extractDshPaths(exec) {
|
|
25
|
+
const args = exec.arguments;
|
|
26
|
+
if ((exec.name === "write" || exec.name === "edit") &&
|
|
27
|
+
typeof args === "object" &&
|
|
28
|
+
args !== null) {
|
|
29
|
+
const record = args;
|
|
30
|
+
const snake = record["file_path"];
|
|
31
|
+
if (typeof snake === "string" && snake !== "") {
|
|
32
|
+
return [snake];
|
|
33
|
+
}
|
|
34
|
+
const camel = extractFilePath(args);
|
|
35
|
+
if (camel !== undefined) {
|
|
36
|
+
return [camel];
|
|
37
|
+
}
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
if (exec.name === "apply_patch" && typeof args === "object" && args !== null) {
|
|
41
|
+
const input = args["input"];
|
|
42
|
+
if (typeof input !== "string") {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
const paths = [];
|
|
46
|
+
for (const m of input.matchAll(/^\*\*\* (?:Add File|Update File|Move to|Delete File): (.+)$/gm)) {
|
|
47
|
+
const p = m[1].trim();
|
|
48
|
+
if (p !== "") {
|
|
49
|
+
paths.push(p);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return paths;
|
|
53
|
+
}
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
/** Shell command string for `bash`/`shell` tools, if present. */
|
|
57
|
+
export function extractDshCommand(exec) {
|
|
58
|
+
if (exec.name !== "bash" && exec.name !== "shell") {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
return extractCommand(exec.arguments);
|
|
62
|
+
}
|