opencode-dev-framework 1.9.5 → 1.10.1
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} +120 -235
- 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/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} +9 -1
- package/dist/{review.js → core/review.js} +14 -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 +23 -8
- 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/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/{logger.js → core/logger.js} +0 -0
- /package/dist/{registry.js → core/registry.js} +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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { loadConfig } from "./config.js";
|
|
2
|
+
import { existingConfigPath, loadConfig } from "./config.js";
|
|
3
3
|
import { inspectCompletion } from "./harness.js";
|
|
4
4
|
import { setProfileInFile } from "./installer.js";
|
|
5
5
|
import { createLintLimiter } from "./lint.js";
|
|
@@ -11,7 +11,9 @@ import { createLintLimiter } from "./lint.js";
|
|
|
11
11
|
* `dev_framework_set_profile` custom tool.
|
|
12
12
|
*/
|
|
13
13
|
export async function changeProfile(directory, profile) {
|
|
14
|
-
|
|
14
|
+
// New file only when no config exists under any supported name; an
|
|
15
|
+
// established deployment is edited in place, never shadowed.
|
|
16
|
+
const configPath = existingConfigPath(directory) ?? join(directory, ".dev-framework.yml");
|
|
15
17
|
await setProfileInFile(configPath, profile);
|
|
16
18
|
return `opencode-dev-framework profile set to "${profile}". Change applies on the next tool call / gate run.`;
|
|
17
19
|
}
|
|
@@ -5,17 +5,29 @@
|
|
|
5
5
|
* docs/plans/03-config-spec.md.
|
|
6
6
|
*/
|
|
7
7
|
import type { Config, ResolvedConfig } from "./types.js";
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Config file precedence, highest first. The first file found wins.
|
|
10
|
+
* The neutral `.dev-framework.*` names are canonical; the
|
|
11
|
+
* `.opencode-dev-framework.*` names stay readable so existing
|
|
12
|
+
* deployments keep working without moving their config.
|
|
13
|
+
*/
|
|
14
|
+
export declare const CONFIG_FILE_PRECEDENCE: readonly [".dev-framework.yml", ".dev-framework.yaml", ".dev-framework.json", ".opencode-dev-framework.yml", ".opencode-dev-framework.yaml", ".opencode-dev-framework.json"];
|
|
10
15
|
/** Sensible default protected paths, used when `protect` is omitted. */
|
|
11
16
|
export declare const DEFAULT_PROTECT: string[];
|
|
17
|
+
/** Highest-precedence existing config path, or undefined when no
|
|
18
|
+
* config file exists under any supported name. Writers use this so a
|
|
19
|
+
* legacy-named deployment is edited in place instead of shadowed. */
|
|
20
|
+
export declare function existingConfigPath(directory: string): string | undefined;
|
|
21
|
+
/** Newest mtime across all six supported config names; undefined when none exists. */
|
|
22
|
+
export declare function configMtimeMs(directory: string): number | undefined;
|
|
12
23
|
/** Find the highest-precedence config file in a directory, if any. */
|
|
13
24
|
export declare function findConfigFile(directory: string): string | undefined;
|
|
14
25
|
/** Split a whitespace-separated glob string (or pass through an array). */
|
|
15
26
|
export declare function splitGlobs(value: unknown): string[];
|
|
16
27
|
/**
|
|
17
|
-
* Map a flat-key
|
|
18
|
-
*
|
|
28
|
+
* Map a flat-key YAML document onto the native config shape. Tried
|
|
29
|
+
* whenever the native shape fails to validate (any `.yml`/`.yaml`
|
|
30
|
+
* name); unknown keys are ignored. See the compatibility table in
|
|
19
31
|
* docs/plans/03-config-spec.md.
|
|
20
32
|
*/
|
|
21
33
|
export declare function mapFlatConfig(flat: Record<string, unknown>): Config;
|
|
@@ -4,20 +4,25 @@
|
|
|
4
4
|
* Implements the precedence, validation, and profile-default rules from
|
|
5
5
|
* docs/plans/03-config-spec.md.
|
|
6
6
|
*/
|
|
7
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
8
|
-
import {
|
|
7
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
9
|
import { parse as parseYaml } from "yaml";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
import { normalizeCommandMap } from "./command-utils.js";
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Config file precedence, highest first. The first file found wins.
|
|
14
|
+
* The neutral `.dev-framework.*` names are canonical; the
|
|
15
|
+
* `.opencode-dev-framework.*` names stay readable so existing
|
|
16
|
+
* deployments keep working without moving their config.
|
|
17
|
+
*/
|
|
13
18
|
export const CONFIG_FILE_PRECEDENCE = [
|
|
19
|
+
".dev-framework.yml",
|
|
20
|
+
".dev-framework.yaml",
|
|
21
|
+
".dev-framework.json",
|
|
14
22
|
".opencode-dev-framework.yml",
|
|
15
23
|
".opencode-dev-framework.yaml",
|
|
16
24
|
".opencode-dev-framework.json",
|
|
17
|
-
".dev-framework.yml",
|
|
18
|
-
".dev-framework.yaml",
|
|
19
25
|
];
|
|
20
|
-
const FALLBACK_FILES = new Set([".dev-framework.yml", ".dev-framework.yaml"]);
|
|
21
26
|
/** Sensible default protected paths, used when `protect` is omitted. */
|
|
22
27
|
export const DEFAULT_PROTECT = [
|
|
23
28
|
".env",
|
|
@@ -108,6 +113,28 @@ const configSchema = z.object({
|
|
|
108
113
|
style_guide: z.string().optional(),
|
|
109
114
|
precommit: z.enum(["auto", "off"]).optional(),
|
|
110
115
|
});
|
|
116
|
+
/** Highest-precedence existing config path, or undefined when no
|
|
117
|
+
* config file exists under any supported name. Writers use this so a
|
|
118
|
+
* legacy-named deployment is edited in place instead of shadowed. */
|
|
119
|
+
export function existingConfigPath(directory) {
|
|
120
|
+
return findConfigFile(directory);
|
|
121
|
+
}
|
|
122
|
+
/** Newest mtime across all six supported config names; undefined when none exists. */
|
|
123
|
+
export function configMtimeMs(directory) {
|
|
124
|
+
let newest;
|
|
125
|
+
for (const name of CONFIG_FILE_PRECEDENCE) {
|
|
126
|
+
try {
|
|
127
|
+
const mtimeMs = statSync(join(directory, name)).mtimeMs;
|
|
128
|
+
if (newest === undefined || mtimeMs > newest) {
|
|
129
|
+
newest = mtimeMs;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// name absent
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return newest;
|
|
137
|
+
}
|
|
111
138
|
/** Find the highest-precedence config file in a directory, if any. */
|
|
112
139
|
export function findConfigFile(directory) {
|
|
113
140
|
for (const name of CONFIG_FILE_PRECEDENCE) {
|
|
@@ -154,8 +181,9 @@ function toNumber(value) {
|
|
|
154
181
|
return undefined;
|
|
155
182
|
}
|
|
156
183
|
/**
|
|
157
|
-
* Map a flat-key
|
|
158
|
-
*
|
|
184
|
+
* Map a flat-key YAML document onto the native config shape. Tried
|
|
185
|
+
* whenever the native shape fails to validate (any `.yml`/`.yaml`
|
|
186
|
+
* name); unknown keys are ignored. See the compatibility table in
|
|
159
187
|
* docs/plans/03-config-spec.md.
|
|
160
188
|
*/
|
|
161
189
|
export function mapFlatConfig(flat) {
|
|
@@ -179,6 +207,12 @@ export function mapFlatConfig(flat) {
|
|
|
179
207
|
return false;
|
|
180
208
|
};
|
|
181
209
|
for (const [key, value] of Object.entries(flat)) {
|
|
210
|
+
// Skip commented-out debris: an explicitly empty key parses as null
|
|
211
|
+
// and must not coerce to a live value (`String(null)` → "null" as a
|
|
212
|
+
// gate command, `splitGlobs(null)` → [] silently disabling protection).
|
|
213
|
+
if (value === null || value === undefined) {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
182
216
|
if (key.startsWith("format.")) {
|
|
183
217
|
const ext = key.slice("format.".length);
|
|
184
218
|
formatByExt[ext.startsWith(".") ? ext : `.${ext}`] = String(value);
|
|
@@ -438,6 +472,63 @@ function validateConfig(data, configPath) {
|
|
|
438
472
|
return { ...config, preflight };
|
|
439
473
|
}
|
|
440
474
|
const configCache = new Map();
|
|
475
|
+
/** Keys that only exist in the native config shape (the flat mapper
|
|
476
|
+
* drops them). Their presence means the document is attempting native
|
|
477
|
+
* shape — see selectConfigRecord below. Scalar keys (`profile`,
|
|
478
|
+
* `protect`, `protect_mode`, `exclude`, `preflight`, ...) are
|
|
479
|
+
* dual-shape — the flat mapper handles both forms — as are
|
|
480
|
+
* string/array `rules` (only the `{ mode, files }` object form counts
|
|
481
|
+
* as native here). */
|
|
482
|
+
const NATIVE_OBJECT_KEYS = ["commands", "gate", "on_edit"];
|
|
483
|
+
/** Keys the native schema strips but the flat mapper honors: present
|
|
484
|
+
* alongside a native key, they would be silently dropped. */
|
|
485
|
+
const FLAT_ONLY_KEYS = new Set([
|
|
486
|
+
"test",
|
|
487
|
+
"typecheck",
|
|
488
|
+
"format",
|
|
489
|
+
"lint",
|
|
490
|
+
"test_changed",
|
|
491
|
+
"format_on_edit",
|
|
492
|
+
"lint_on_edit",
|
|
493
|
+
"gate_run_typecheck",
|
|
494
|
+
"gate_run_tests",
|
|
495
|
+
"gate_block_on_failure",
|
|
496
|
+
"gate_skip_unchanged",
|
|
497
|
+
"gate_scope",
|
|
498
|
+
"gate_lint_changed",
|
|
499
|
+
"gate_require_review",
|
|
500
|
+
"gate_timeout",
|
|
501
|
+
"gate_max_blocks",
|
|
502
|
+
]);
|
|
503
|
+
function isFlatDottedKey(key) {
|
|
504
|
+
return key.startsWith("format.") || key.startsWith("lint.");
|
|
505
|
+
}
|
|
506
|
+
/** Select the document validateConfig will check: native shape when the
|
|
507
|
+
* document uses native-only keys, flat mapping otherwise. Null-valued
|
|
508
|
+
* keys (commented-out YAML debris) count as absent for sniffing. A
|
|
509
|
+
* document mixing both shapes fails loudly naming the dropped flat
|
|
510
|
+
* keys, instead of silently running a different gate than written.
|
|
511
|
+
* Either name accepts either shape; JSON stays native-only. */
|
|
512
|
+
function selectConfigRecord(configPath, asRecord) {
|
|
513
|
+
const keys = Object.keys(asRecord).filter((key) => asRecord[key] !== null && asRecord[key] !== undefined);
|
|
514
|
+
if (configPath.endsWith(".json")) {
|
|
515
|
+
return asRecord;
|
|
516
|
+
}
|
|
517
|
+
const nativeHit = NATIVE_OBJECT_KEYS.some((key) => keys.includes(key)) ||
|
|
518
|
+
(typeof asRecord["rules"] === "object" &&
|
|
519
|
+
asRecord["rules"] !== null &&
|
|
520
|
+
!Array.isArray(asRecord["rules"]));
|
|
521
|
+
if (!nativeHit) {
|
|
522
|
+
return mapFlatConfig(asRecord);
|
|
523
|
+
}
|
|
524
|
+
const dropped = keys.filter((key) => FLAT_ONLY_KEYS.has(key) || isFlatDottedKey(key));
|
|
525
|
+
if (dropped.length > 0) {
|
|
526
|
+
throw new Error(`Invalid configuration in ${configPath}: mixes native and flat keys ` +
|
|
527
|
+
`(flat keys ${dropped.join(", ")} are ignored when native keys are present). ` +
|
|
528
|
+
`Move them into commands:/gate:/on_edit: or drop the native keys to use flat shape.`);
|
|
529
|
+
}
|
|
530
|
+
return asRecord;
|
|
531
|
+
}
|
|
441
532
|
/** Clear the per-session config cache (mainly for tests). */
|
|
442
533
|
export function clearConfigCache() {
|
|
443
534
|
configCache.clear();
|
|
@@ -461,8 +552,9 @@ export function loadConfig(directory) {
|
|
|
461
552
|
const asRecord = typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)
|
|
462
553
|
? parsed
|
|
463
554
|
: {};
|
|
464
|
-
|
|
465
|
-
|
|
555
|
+
// Shape-sniffed: native keys validate natively, flat keys map over.
|
|
556
|
+
// Either name accepts either shape.
|
|
557
|
+
resolved = resolveConfig(validateConfig(selectConfigRecord(configPath, asRecord), configPath), configPath);
|
|
466
558
|
}
|
|
467
559
|
configCache.set(directory, resolved);
|
|
468
560
|
return resolved;
|
|
@@ -12,8 +12,17 @@ export declare function renderTemplateState(templates: TemplateState | undefined
|
|
|
12
12
|
*
|
|
13
13
|
* This is shared between the server-side `/df-status` tool and the TUI plugin,
|
|
14
14
|
* which does not have access to live hook state.
|
|
15
|
+
*
|
|
16
|
+
* `formatOwner` names who runs the configured formatter, because it differs
|
|
17
|
+
* by host: OpenCode core formats (the plugin only lints), while the DSH
|
|
18
|
+
* adapter formats in post-execute. Closed vocabulary (mirroring the
|
|
19
|
+
* `skillAccess` capability flag in `init.ts`): core owns both wordings, so
|
|
20
|
+
* no caller can inject display prose into shared output. The default
|
|
21
|
+
* preserves the OpenCode text so existing callers read unchanged.
|
|
15
22
|
*/
|
|
16
|
-
export declare function renderConfigStatus(config: ResolvedConfig
|
|
23
|
+
export declare function renderConfigStatus(config: ResolvedConfig, options?: {
|
|
24
|
+
formatOwner?: "core" | "adapter";
|
|
25
|
+
}): string;
|
|
17
26
|
/**
|
|
18
27
|
* Render a help message listing the available dev-framework slash commands.
|
|
19
28
|
*/
|
|
@@ -24,7 +33,9 @@ export declare function renderHelp(): string;
|
|
|
24
33
|
* Used by the `dev_framework_status` custom tool and by the server-side
|
|
25
34
|
* slash-command handler.
|
|
26
35
|
*/
|
|
27
|
-
export declare function renderStatus(config: ResolvedConfig, state?: HookState | null
|
|
36
|
+
export declare function renderStatus(config: ResolvedConfig, state?: HookState | null, options?: {
|
|
37
|
+
formatOwner?: "core" | "adapter";
|
|
38
|
+
}): string;
|
|
28
39
|
/**
|
|
29
40
|
* Render the runtime snapshot for the TUI `/df-runtime` command: plugin
|
|
30
41
|
* version, which session-hook method the core accepted, dispatch
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PREFLIGHT_ARTIFACT_REL } from "./paths.js";
|
|
1
2
|
/**
|
|
2
3
|
* One-line template drift state for `/df-runtime`: up to date, drifted
|
|
3
4
|
* (run `/df-update`), or nothing installed (run `/df-init`). Absent
|
|
@@ -50,8 +51,16 @@ function formatRules(rules) {
|
|
|
50
51
|
*
|
|
51
52
|
* This is shared between the server-side `/df-status` tool and the TUI plugin,
|
|
52
53
|
* which does not have access to live hook state.
|
|
54
|
+
*
|
|
55
|
+
* `formatOwner` names who runs the configured formatter, because it differs
|
|
56
|
+
* by host: OpenCode core formats (the plugin only lints), while the DSH
|
|
57
|
+
* adapter formats in post-execute. Closed vocabulary (mirroring the
|
|
58
|
+
* `skillAccess` capability flag in `init.ts`): core owns both wordings, so
|
|
59
|
+
* no caller can inject display prose into shared output. The default
|
|
60
|
+
* preserves the OpenCode text so existing callers read unchanged.
|
|
53
61
|
*/
|
|
54
|
-
export function renderConfigStatus(config) {
|
|
62
|
+
export function renderConfigStatus(config, options) {
|
|
63
|
+
const adapterFormats = options?.formatOwner === "adapter";
|
|
55
64
|
const lines = [];
|
|
56
65
|
lines.push(`opencode-dev-framework status`);
|
|
57
66
|
lines.push("");
|
|
@@ -72,7 +81,7 @@ export function renderConfigStatus(config) {
|
|
|
72
81
|
}
|
|
73
82
|
lines.push("");
|
|
74
83
|
lines.push("On edit:");
|
|
75
|
-
lines.push(` format: ${config.on_edit.format} (ignored — formatting is OpenCode core's job)`);
|
|
84
|
+
lines.push(` format: ${config.on_edit.format} (${adapterFormats ? "run by this adapter — format-then-lint in post-execute" : "ignored — formatting is OpenCode core's job"})`);
|
|
76
85
|
lines.push(` lint: ${config.on_edit.lint}`);
|
|
77
86
|
lines.push(` precommit: ${config.precommit}`);
|
|
78
87
|
lines.push("");
|
|
@@ -92,7 +101,7 @@ export function renderConfigStatus(config) {
|
|
|
92
101
|
lines.push(" (disabled — no preflight tasks configured)");
|
|
93
102
|
}
|
|
94
103
|
else {
|
|
95
|
-
lines.push(` artifact:
|
|
104
|
+
lines.push(` artifact: ${PREFLIGHT_ARTIFACT_REL}`);
|
|
96
105
|
lines.push(" tasks:");
|
|
97
106
|
for (const task of config.preflight) {
|
|
98
107
|
lines.push(` - ${task}`);
|
|
@@ -108,7 +117,9 @@ export function renderConfigStatus(config) {
|
|
|
108
117
|
lines.push(config.commands.test_changed ? ` ${config.commands.test_changed}` : " (not configured)");
|
|
109
118
|
lines.push(" lint:");
|
|
110
119
|
lines.push(formatCommandMap(config.commands.lint, " "));
|
|
111
|
-
lines.push(
|
|
120
|
+
lines.push(adapterFormats
|
|
121
|
+
? " format: (run by this adapter — format-then-lint in post-execute)"
|
|
122
|
+
: " format: (ignored — formatting is OpenCode core's job)");
|
|
112
123
|
lines.push(formatCommandMap(config.commands.format, " "));
|
|
113
124
|
lines.push("");
|
|
114
125
|
lines.push("Constitution rules:");
|
|
@@ -141,8 +152,8 @@ export function renderHelp() {
|
|
|
141
152
|
* Used by the `dev_framework_status` custom tool and by the server-side
|
|
142
153
|
* slash-command handler.
|
|
143
154
|
*/
|
|
144
|
-
export function renderStatus(config, state) {
|
|
145
|
-
const lines = [renderConfigStatus(config)];
|
|
155
|
+
export function renderStatus(config, state, options) {
|
|
156
|
+
const lines = [renderConfigStatus(config, options)];
|
|
146
157
|
if (state) {
|
|
147
158
|
// Enforcement level: the `experimental.idle` hook (same-execution
|
|
148
159
|
// synthetic continuation) once it has completed an evaluation, else
|
|
@@ -172,6 +183,16 @@ export function renderStatus(config, state) {
|
|
|
172
183
|
lines.push(` ${sessionID}: ${count}/${config.gate.max_blocks}`);
|
|
173
184
|
}
|
|
174
185
|
}
|
|
186
|
+
if (state.seams !== undefined) {
|
|
187
|
+
lines.push("");
|
|
188
|
+
lines.push("Host seams:");
|
|
189
|
+
lines.push(` tools: ${state.seams.tools ? "available (agent tools live)" : "unavailable (commands only)"}`);
|
|
190
|
+
lines.push(` goals: ${state.seams.goals ? "available" : "unavailable (df-goal degrades to error text)"}`);
|
|
191
|
+
lines.push(` approval: ${state.seams.approval ? "available (warns ask the human)" : "unavailable (warns allow + log)"}`);
|
|
192
|
+
lines.push(` subagents: ${state.seams.subagents ? "available (specialists dispatch as children)" : "unavailable (review runs inline)"}`);
|
|
193
|
+
lines.push(` presets: ${state.seams.agentPresets ? "available (reviewers run read-only)" : "unavailable (prompt-level restriction + guards)"}`);
|
|
194
|
+
lines.push(` sessionQuery: ${state.seams.sessionQuery ? "available (continuity probe reads the session log)" : "unavailable (continuity unknown)"}`);
|
|
195
|
+
}
|
|
175
196
|
}
|
|
176
197
|
return lines.join("\n");
|
|
177
198
|
}
|
|
@@ -193,7 +214,9 @@ export function renderRuntimeStatus(snapshot) {
|
|
|
193
214
|
lines.push(renderTemplateState(snapshot.templates));
|
|
194
215
|
lines.push(snapshot.idleHookVia === "none"
|
|
195
216
|
? "Idle hook: not registered — event-subscribe fallback only"
|
|
196
|
-
:
|
|
217
|
+
: snapshot.idleHookVia === "turn-stopping"
|
|
218
|
+
? "Turn-stopping hook: pre-terminal — standard/strict red gates block stopping until pass or stand-down"
|
|
219
|
+
: `Idle hook: registered via ${snapshot.idleHookVia}`);
|
|
197
220
|
if (snapshot.continuation === "idle") {
|
|
198
221
|
lines.push("Continuation: active — gate failures continue the same execution");
|
|
199
222
|
}
|
|
@@ -15,7 +15,15 @@ import type { ResolvedConfig } from "./types.js";
|
|
|
15
15
|
export declare const DEFAULT_GATE_TIMEOUT_SECONDS = 300;
|
|
16
16
|
/** Tracks files edited during a session so the gate can scope work. */
|
|
17
17
|
export interface ChangedFileTracker {
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Record a file. Returns false (recording nothing) when an absolute path
|
|
20
|
+
* resolves outside `directory`: the gate is project-scoped, and tracking
|
|
21
|
+
* an out-of-tree file would demand the review name a `../` path no
|
|
22
|
+
* artifact can cover. Host filesystem watchers report whatever changed
|
|
23
|
+
* on disk (including sibling repos' `.git/` metadata), so this is the
|
|
24
|
+
* choke point that keeps the changed set in-tree for every adapter.
|
|
25
|
+
*/
|
|
26
|
+
add: (filePath: string, directory?: string) => boolean;
|
|
19
27
|
/** True when the (normalized) path is already tracked. */
|
|
20
28
|
has: (filePath: string, directory?: string) => boolean;
|
|
21
29
|
getChangedFiles: () => string[];
|
|
@@ -9,11 +9,18 @@
|
|
|
9
9
|
* hook skips.
|
|
10
10
|
*/
|
|
11
11
|
import { existsSync } from "node:fs";
|
|
12
|
-
import { isAbsolute, relative } from "node:path";
|
|
12
|
+
import { isAbsolute, relative, sep } from "node:path";
|
|
13
13
|
import { splitCommand, toAbsolutePath } from "./command-utils.js";
|
|
14
14
|
import { lintFile, MAX_CONCURRENT_LINTS } from "./lint.js";
|
|
15
15
|
/** Fallback per-command timeout (seconds) when `gate.timeout` is unset. */
|
|
16
16
|
export const DEFAULT_GATE_TIMEOUT_SECONDS = 300;
|
|
17
|
+
/** True when a normalized candidate escapes the project directory. */
|
|
18
|
+
function escapesDirectory(candidate) {
|
|
19
|
+
return (candidate === ".." ||
|
|
20
|
+
candidate.startsWith(`..${sep}`) ||
|
|
21
|
+
candidate.startsWith("../") ||
|
|
22
|
+
candidate.startsWith("..\\"));
|
|
23
|
+
}
|
|
17
24
|
function normalizeTrackedPath(filePath, directory) {
|
|
18
25
|
let candidate = filePath;
|
|
19
26
|
if (directory !== undefined && isAbsolute(filePath)) {
|
|
@@ -29,7 +36,12 @@ export function createChangedFileTracker() {
|
|
|
29
36
|
const files = new Set();
|
|
30
37
|
return {
|
|
31
38
|
add(filePath, directory) {
|
|
32
|
-
|
|
39
|
+
const candidate = normalizeTrackedPath(filePath, directory);
|
|
40
|
+
if (escapesDirectory(candidate)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
files.add(candidate);
|
|
44
|
+
return true;
|
|
33
45
|
},
|
|
34
46
|
has(filePath, directory) {
|
|
35
47
|
return files.has(normalizeTrackedPath(filePath, directory));
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
* kickoff, state, reviewer, pause/resume/clear, and continuations; the
|
|
9
9
|
* framework's idle gate stays the independent deterministic backstop.
|
|
10
10
|
*
|
|
11
|
-
* All policy here is pure (input -> data, no session I/O):
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* All policy here is pure (input -> data, no session I/O): the OpenCode
|
|
12
|
+
* adapter (`src/adapters/opencode/index.ts`) owns the
|
|
13
|
+
* `ctx.command.transform` registration, the `command.list()` call, and the
|
|
14
|
+
* delegation call; the shape-tolerant listing predicate
|
|
14
15
|
* (`isNativeGoalListed`) lives here. Unit tests drive these functions
|
|
15
16
|
* with a stub delegate.
|
|
16
17
|
*/
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
* kickoff, state, reviewer, pause/resume/clear, and continuations; the
|
|
9
9
|
* framework's idle gate stays the independent deterministic backstop.
|
|
10
10
|
*
|
|
11
|
-
* All policy here is pure (input -> data, no session I/O):
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* All policy here is pure (input -> data, no session I/O): the OpenCode
|
|
12
|
+
* adapter (`src/adapters/opencode/index.ts`) owns the
|
|
13
|
+
* `ctx.command.transform` registration, the `command.list()` call, and the
|
|
14
|
+
* delegation call; the shape-tolerant listing predicate
|
|
14
15
|
* (`isNativeGoalListed`) lives here. Unit tests drive these functions
|
|
15
16
|
* with a stub delegate.
|
|
16
17
|
*/
|
|
@@ -21,11 +21,11 @@ import { type ChangedFileTracker, type GateReport } from "./gate.js";
|
|
|
21
21
|
import type { RunCommand } from "./host.js";
|
|
22
22
|
import type { LintLimiter } from "./lint.js";
|
|
23
23
|
import type { LogFn } from "./logger.js";
|
|
24
|
+
import { LEGACY_PREFLIGHT_ARTIFACT_REL, LEGACY_REVIEW_ARTIFACT_REL, PREFLIGHT_ARTIFACT_REL, REVIEW_ARTIFACT_REL } from "./paths.js";
|
|
24
25
|
import { type ReviewState } from "./review.js";
|
|
26
|
+
export { LEGACY_PREFLIGHT_ARTIFACT_REL, LEGACY_REVIEW_ARTIFACT_REL, PREFLIGHT_ARTIFACT_REL, REVIEW_ARTIFACT_REL, };
|
|
25
27
|
import type { ResolvedConfig } from "./types.js";
|
|
26
28
|
import { type EnforceableSnapshot } from "./weakening.js";
|
|
27
|
-
/** Project-relative path of the peer-review artifact the agent must produce. */
|
|
28
|
-
export declare const REVIEW_ARTIFACT_REL = ".opencode/opencode-dev-framework/review.md";
|
|
29
29
|
/**
|
|
30
30
|
* True when a tool-call target is the review artifact. Normalizes like the
|
|
31
31
|
* guardrail path matcher (absolute paths resolve against the project
|
|
@@ -41,8 +41,6 @@ export declare function isReviewArtifact(filePath: string, directory?: string):
|
|
|
41
41
|
* never update one site and miss the other.
|
|
42
42
|
*/
|
|
43
43
|
export declare function childArtifactDenial(): string;
|
|
44
|
-
/** Project-relative path of the pre-flight artifact the agent must produce. */
|
|
45
|
-
export declare const PREFLIGHT_ARTIFACT_REL = ".opencode/opencode-dev-framework/preflight.md";
|
|
46
44
|
/**
|
|
47
45
|
* Consecutive no-progress repeats before early stand-down (docs/plans/14-stuck-detection.md): the
|
|
48
46
|
* third identical blocked evaluation (two repeats) stands down. One
|
|
@@ -52,6 +50,13 @@ export declare const PREFLIGHT_ARTIFACT_REL = ".opencode/opencode-dev-framework/
|
|
|
52
50
|
*/
|
|
53
51
|
export declare const NO_PROGRESS_REPEATS = 2;
|
|
54
52
|
export type ArtifactState = "missing" | "empty" | "present";
|
|
53
|
+
/**
|
|
54
|
+
* Inspect artifact files, new location first: present (non-trivial
|
|
55
|
+
* content), empty, or missing. The first non-missing candidate wins, so
|
|
56
|
+
* an agent mid-migration (both files present) answers from the new one.
|
|
57
|
+
* Never throws — unreadable files count as missing.
|
|
58
|
+
*/
|
|
59
|
+
export declare function artifactStateFirst(directory: string, rels: readonly string[]): Promise<ArtifactState>;
|
|
55
60
|
/**
|
|
56
61
|
* Inspect an artifact file: present (non-trivial content), empty, or missing.
|
|
57
62
|
* Never throws — unreadable files count as missing.
|
|
@@ -100,7 +105,7 @@ export declare function mergeChangedFiles(trackerFiles: string[], gitFiles: stri
|
|
|
100
105
|
* Blocking only applies to standard/strict; advisory callers should treat a
|
|
101
106
|
* non-null reason as a warning instead of a denial.
|
|
102
107
|
*/
|
|
103
|
-
export declare function preflightBlockReason(config: ResolvedConfig, toolName: string, targetFile: string | undefined, artifact: ArtifactState): string | null;
|
|
108
|
+
export declare function preflightBlockReason(config: ResolvedConfig, toolName: string, targetFile: string | undefined, artifact: ArtifactState, directory?: string): string | null;
|
|
104
109
|
export type CompletionVerdict = {
|
|
105
110
|
decision: "pass";
|
|
106
111
|
changedFiles: string[];
|