opencode-dev-framework 1.11.1 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -5
- package/dist/adapters/dsh/extract.js +2 -2
- package/dist/adapters/dsh/index.d.ts +71 -0
- package/dist/adapters/dsh/index.js +232 -11
- package/dist/adapters/opencode/index.js +78 -4
- package/dist/core/commands.d.ts +36 -1
- package/dist/core/commands.js +122 -2
- package/dist/core/config.js +9 -3
- package/dist/core/format-status.js +1 -0
- package/dist/core/harness.d.ts +26 -0
- package/dist/core/harness.js +48 -2
- package/dist/core/install-dsh.js +1 -1
- package/dist/core/installer.d.ts +12 -0
- package/dist/core/installer.js +141 -0
- package/dist/core/logger.d.ts +3 -21
- package/dist/core/logger.js +3 -24
- package/dist/core/run-hooks.d.ts +7 -0
- package/dist/core/run-hooks.js +1 -0
- package/dist/core/types.d.ts +8 -0
- package/package.json +1 -1
- package/rules/10-quality-bar.md +5 -0
- package/templates/.opencode/agents/code-reviewer.md +7 -1
- package/templates/.opencode/agents/pattern-guardian.md +7 -1
- package/templates/.opencode/agents/style-enforcer.md +7 -1
- package/templates/.opencode/agents/test-grounder.md +4 -1
- package/templates/.opencode/skills/project-config/SKILL.md +6 -1
package/dist/core/commands.d.ts
CHANGED
|
@@ -34,4 +34,39 @@ export interface VerifyResult {
|
|
|
34
34
|
* `changedFiles` is normally the server's live tracker snapshot (empty for
|
|
35
35
|
* TUI callers); Git-discovered files are unioned in either way.
|
|
36
36
|
*/
|
|
37
|
-
export declare function verifyGate(run: RunCommand, directory: string, config?: ResolvedConfig, changedFiles?: string[]): Promise<VerifyResult>;
|
|
37
|
+
export declare function verifyGate(run: RunCommand, directory: string, config?: ResolvedConfig, changedFiles?: string[], sessionIgnores?: readonly string[]): Promise<VerifyResult>;
|
|
38
|
+
/** Parsed `/df-ignore` arguments. `patterns` add to the session hotlist,
|
|
39
|
+
* `remove` drops from it, `store` persists, `list` reports. Bare
|
|
40
|
+
* invocation (everything empty) lists. */
|
|
41
|
+
export interface DfIgnoreArgs {
|
|
42
|
+
patterns: string[];
|
|
43
|
+
store: boolean;
|
|
44
|
+
list: boolean;
|
|
45
|
+
remove: string[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parse `/df-ignore` raw input (the DSH slash form). Flags anywhere:
|
|
49
|
+
* `-s|--store`, `-l|--list`, `-r|--remove` (following non-flag tokens are
|
|
50
|
+
* removals), `--` ends flag parsing. Quote-aware via `splitCommand`, so
|
|
51
|
+
* patterns with spaces quote (`"my dir/**"`). Throws a readable error on
|
|
52
|
+
* unknown flags instead of silently ignoring them.
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseIgnoreArgs(rawInput: string): DfIgnoreArgs;
|
|
55
|
+
export interface DfIgnoreResult {
|
|
56
|
+
message: string;
|
|
57
|
+
added: string[];
|
|
58
|
+
alreadyPresent: string[];
|
|
59
|
+
removed: string[];
|
|
60
|
+
notFound: string[];
|
|
61
|
+
stored: string[];
|
|
62
|
+
sessionIgnores: string[];
|
|
63
|
+
configIgnores: string[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Run the `/df-ignore` hotlist command: session add/remove in place (the
|
|
67
|
+
* caller's live array, so the shared glob-matcher cache stays hot),
|
|
68
|
+
* optional `-s` persistence to the config file, `-l`/bare listing of both
|
|
69
|
+
* sources. Storing writes the file but does not reload it — the caller
|
|
70
|
+
* refreshes its in-memory config the way `/df-profile` does.
|
|
71
|
+
*/
|
|
72
|
+
export declare function dfIgnore(directory: string, sessionIgnores: string[], config: ResolvedConfig, args: DfIgnoreArgs): Promise<DfIgnoreResult>;
|
package/dist/core/commands.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
+
import { splitCommand } from "./command-utils.js";
|
|
2
3
|
import { existingConfigPath, loadConfig } from "./config.js";
|
|
3
4
|
import { inspectCompletion } from "./harness.js";
|
|
4
|
-
import { setProfileInFile } from "./installer.js";
|
|
5
|
+
import { setProfileInFile, storeGateIgnores } from "./installer.js";
|
|
5
6
|
import { createLintLimiter } from "./lint.js";
|
|
6
7
|
/**
|
|
7
8
|
* Change the project profile by editing the config file on disk. The server
|
|
@@ -29,13 +30,14 @@ export async function changeProfile(directory, profile) {
|
|
|
29
30
|
* `changedFiles` is normally the server's live tracker snapshot (empty for
|
|
30
31
|
* TUI callers); Git-discovered files are unioned in either way.
|
|
31
32
|
*/
|
|
32
|
-
export async function verifyGate(run, directory, config, changedFiles = []) {
|
|
33
|
+
export async function verifyGate(run, directory, config, changedFiles = [], sessionIgnores = []) {
|
|
33
34
|
const cfg = config ?? loadConfig(directory);
|
|
34
35
|
const inspection = await inspectCompletion({
|
|
35
36
|
run,
|
|
36
37
|
config: cfg,
|
|
37
38
|
directory,
|
|
38
39
|
trackerFiles: changedFiles,
|
|
40
|
+
sessionIgnores,
|
|
39
41
|
// Fresh limiter per manual verify (bounds its own lint burst); no pass
|
|
40
42
|
// cache — an explicit verify always inspects the live tree.
|
|
41
43
|
lintLimiter: createLintLimiter(),
|
|
@@ -44,3 +46,121 @@ export async function verifyGate(run, directory, config, changedFiles = []) {
|
|
|
44
46
|
const summary = `DEV_FRAMEWORK_VERDICT: ${verdict}\n${inspection.summary}`;
|
|
45
47
|
return { report: inspection.report, inspection, verdict, summary };
|
|
46
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Parse `/df-ignore` raw input (the DSH slash form). Flags anywhere:
|
|
51
|
+
* `-s|--store`, `-l|--list`, `-r|--remove` (following non-flag tokens are
|
|
52
|
+
* removals), `--` ends flag parsing. Quote-aware via `splitCommand`, so
|
|
53
|
+
* patterns with spaces quote (`"my dir/**"`). Throws a readable error on
|
|
54
|
+
* unknown flags instead of silently ignoring them.
|
|
55
|
+
*/
|
|
56
|
+
export function parseIgnoreArgs(rawInput) {
|
|
57
|
+
const args = { patterns: [], store: false, list: false, remove: [] };
|
|
58
|
+
let toRemove = false;
|
|
59
|
+
let flagsOpen = true;
|
|
60
|
+
for (const token of splitCommand(rawInput)) {
|
|
61
|
+
if (flagsOpen && !toRemove && (token === "-s" || token === "--store")) {
|
|
62
|
+
args.store = true;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (flagsOpen && !toRemove && (token === "-l" || token === "--list")) {
|
|
66
|
+
args.list = true;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (flagsOpen && (token === "-r" || token === "--remove")) {
|
|
70
|
+
toRemove = true;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (flagsOpen && token === "--") {
|
|
74
|
+
flagsOpen = false;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (flagsOpen && !toRemove && token.startsWith("-") && token !== "-") {
|
|
78
|
+
throw new Error(`Unknown /df-ignore flag "${token}". Flags: -s|--store, -l|--list, -r|--remove, -- to end flag parsing.`);
|
|
79
|
+
}
|
|
80
|
+
(toRemove ? args.remove : args.patterns).push(token);
|
|
81
|
+
}
|
|
82
|
+
return args;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Run the `/df-ignore` hotlist command: session add/remove in place (the
|
|
86
|
+
* caller's live array, so the shared glob-matcher cache stays hot),
|
|
87
|
+
* optional `-s` persistence to the config file, `-l`/bare listing of both
|
|
88
|
+
* sources. Storing writes the file but does not reload it — the caller
|
|
89
|
+
* refreshes its in-memory config the way `/df-profile` does.
|
|
90
|
+
*/
|
|
91
|
+
export async function dfIgnore(directory, sessionIgnores, config, args) {
|
|
92
|
+
const added = [];
|
|
93
|
+
const alreadyPresent = [];
|
|
94
|
+
const removed = [];
|
|
95
|
+
const notFound = [];
|
|
96
|
+
let stored = [];
|
|
97
|
+
for (const pattern of args.remove) {
|
|
98
|
+
const index = sessionIgnores.indexOf(pattern);
|
|
99
|
+
if (index !== -1) {
|
|
100
|
+
sessionIgnores.splice(index, 1);
|
|
101
|
+
removed.push(pattern);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
notFound.push(pattern);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
for (const pattern of args.patterns) {
|
|
108
|
+
if (sessionIgnores.includes(pattern)) {
|
|
109
|
+
alreadyPresent.push(pattern);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
sessionIgnores.push(pattern);
|
|
113
|
+
added.push(pattern);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const lines = [];
|
|
117
|
+
if (added.length > 0) {
|
|
118
|
+
lines.push(`Ignored for this session: ${added.join(", ")}.`);
|
|
119
|
+
}
|
|
120
|
+
if (alreadyPresent.length > 0) {
|
|
121
|
+
lines.push(`Already ignored this session: ${alreadyPresent.join(", ")}.`);
|
|
122
|
+
}
|
|
123
|
+
if (removed.length > 0) {
|
|
124
|
+
lines.push(`Removed from session ignores: ${removed.join(", ")}.`);
|
|
125
|
+
}
|
|
126
|
+
if (notFound.length > 0) {
|
|
127
|
+
lines.push(`Not in session ignores: ${notFound.join(", ")}.`);
|
|
128
|
+
}
|
|
129
|
+
if (args.store) {
|
|
130
|
+
const toStore = args.patterns.length > 0 ? args.patterns : [...sessionIgnores];
|
|
131
|
+
if (toStore.length > 0) {
|
|
132
|
+
const configPath = existingConfigPath(directory) ?? join(directory, ".dev-framework.yml");
|
|
133
|
+
stored = await storeGateIgnores(configPath, toStore);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
lines.push(`Nothing to store.`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Post-store snapshot: `stored` holds exactly what the file gained, so
|
|
140
|
+
// the list line reflects the disk state the adapters reload right after.
|
|
141
|
+
const configIgnores = [...config.gate.ignore, ...stored];
|
|
142
|
+
if (args.store && stored.length > 0) {
|
|
143
|
+
lines.push(`Stored permanently (gate.ignore): ${stored.join(", ")}.`);
|
|
144
|
+
}
|
|
145
|
+
else if (args.store && lines[lines.length - 1] !== `Nothing to store.`) {
|
|
146
|
+
lines.push(`Nothing new to store — already in gate.ignore.`);
|
|
147
|
+
}
|
|
148
|
+
if (args.list || lines.length === 0) {
|
|
149
|
+
const session = sessionIgnores.length > 0 ? sessionIgnores.join(", ") : "(none)";
|
|
150
|
+
const storedList = configIgnores.length > 0 ? configIgnores.join(", ") : "(none)";
|
|
151
|
+
lines.push(`Session ignores: ${session}. Config gate.ignore: ${storedList}.`);
|
|
152
|
+
}
|
|
153
|
+
else if (!args.store) {
|
|
154
|
+
lines.push(`Session-scoped only; re-run with -s to store permanently.`);
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
message: lines.join(" "),
|
|
158
|
+
added,
|
|
159
|
+
alreadyPresent,
|
|
160
|
+
removed,
|
|
161
|
+
notFound,
|
|
162
|
+
stored,
|
|
163
|
+
sessionIgnores: [...sessionIgnores],
|
|
164
|
+
configIgnores,
|
|
165
|
+
};
|
|
166
|
+
}
|
package/dist/core/config.js
CHANGED
|
@@ -90,6 +90,7 @@ const configSchema = z.object({
|
|
|
90
90
|
require_review: z.boolean().optional(),
|
|
91
91
|
timeout: z.number().positive().optional(),
|
|
92
92
|
max_blocks: z.number().int().positive().optional(),
|
|
93
|
+
ignore: z.array(z.string()).optional(),
|
|
93
94
|
acceptance: acceptanceListSchema,
|
|
94
95
|
})
|
|
95
96
|
.optional(),
|
|
@@ -275,6 +276,9 @@ export function mapFlatConfig(flat) {
|
|
|
275
276
|
case "gate_max_blocks":
|
|
276
277
|
gate.max_blocks = toNumber(value);
|
|
277
278
|
break;
|
|
279
|
+
case "gate_ignore":
|
|
280
|
+
gate.ignore = splitGlobs(value);
|
|
281
|
+
break;
|
|
278
282
|
case "protect_off":
|
|
279
283
|
config.protect_off = toBoolean(value);
|
|
280
284
|
break;
|
|
@@ -362,6 +366,7 @@ export function resolveConfig(raw, configPath) {
|
|
|
362
366
|
require_review: raw.gate?.require_review ?? profile !== "off",
|
|
363
367
|
timeout: raw.gate?.timeout,
|
|
364
368
|
max_blocks: raw.gate?.max_blocks ?? 3,
|
|
369
|
+
ignore: raw.gate?.ignore ?? [],
|
|
365
370
|
acceptance: raw.gate?.acceptance ?? [],
|
|
366
371
|
},
|
|
367
372
|
on_edit: {
|
|
@@ -499,6 +504,7 @@ const FLAT_ONLY_KEYS = new Set([
|
|
|
499
504
|
"gate_require_review",
|
|
500
505
|
"gate_timeout",
|
|
501
506
|
"gate_max_blocks",
|
|
507
|
+
"gate_ignore",
|
|
502
508
|
]);
|
|
503
509
|
function isFlatDottedKey(key) {
|
|
504
510
|
return key.startsWith("format.") || key.startsWith("lint.");
|
|
@@ -515,9 +521,9 @@ function selectConfigRecord(configPath, asRecord) {
|
|
|
515
521
|
return asRecord;
|
|
516
522
|
}
|
|
517
523
|
const nativeHit = NATIVE_OBJECT_KEYS.some((key) => keys.includes(key)) ||
|
|
518
|
-
(typeof asRecord
|
|
519
|
-
asRecord
|
|
520
|
-
!Array.isArray(asRecord
|
|
524
|
+
(typeof asRecord.rules === "object" &&
|
|
525
|
+
asRecord.rules !== null &&
|
|
526
|
+
!Array.isArray(asRecord.rules));
|
|
521
527
|
if (!nativeHit) {
|
|
522
528
|
return mapFlatConfig(asRecord);
|
|
523
529
|
}
|
|
@@ -139,6 +139,7 @@ export function renderHelp() {
|
|
|
139
139
|
lines.push("/df-status Show the current dev-framework state");
|
|
140
140
|
lines.push("/df-profile Change the profile to off, advisory, standard, or strict");
|
|
141
141
|
lines.push("/df-verify Run the completion gate manually");
|
|
142
|
+
lines.push("/df-ignore Ignore globs for this session (-s stores, -l lists, -r removes)");
|
|
142
143
|
lines.push("/df-goal Start a verified native goal (verification contract + native /goal)");
|
|
143
144
|
lines.push("/df-init Set up this project (scaffold, detected config, trial-run, brief)");
|
|
144
145
|
lines.push("/df-update Check installed templates against shipped (refresh/add, approved per file)");
|
package/dist/core/harness.d.ts
CHANGED
|
@@ -96,6 +96,24 @@ export declare function parseGitStatusPorcelain(stdout: string): string[];
|
|
|
96
96
|
export declare function gitChangedFiles(run: RunCommand, cwd: string): Promise<string[]>;
|
|
97
97
|
/** Union of tracker and git changed files, sorted and deduped. */
|
|
98
98
|
export declare function mergeChangedFiles(trackerFiles: string[], gitFiles: string[]): string[];
|
|
99
|
+
/**
|
|
100
|
+
* Match a file path against the gate-ignore patterns: permanent config
|
|
101
|
+
* (`gate.ignore`) plus this session's `/df-ignore` additions. Returns the
|
|
102
|
+
* matching pattern, or undefined. Mirrors `matchExclude` semantics — paths
|
|
103
|
+
* resolve against the project directory, and patterns without a slash also
|
|
104
|
+
* match basenames at any depth. Matchers compile once per pattern array via
|
|
105
|
+
* the shared `compileGlobMatchers` cache, so callers pass the live arrays
|
|
106
|
+
* (never a spread copy) to keep the cache hot.
|
|
107
|
+
*/
|
|
108
|
+
export declare function matchGateIgnore(config: ResolvedConfig, sessionIgnores: readonly string[], filePath: string, directory?: string): string | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Drop gate-ignored files from a changed-file list. Applied once at the
|
|
111
|
+
* `inspectCompletion` merge point so ignored files leave the whole gate:
|
|
112
|
+
* command steps, review coverage, and the pass-cache fingerprint all read
|
|
113
|
+
* the filtered list. Session additions and permanent config filter
|
|
114
|
+
* identically — permanence differs, behavior does not.
|
|
115
|
+
*/
|
|
116
|
+
export declare function filterGateIgnored(config: ResolvedConfig, sessionIgnores: readonly string[], files: string[], directory?: string): string[];
|
|
99
117
|
/**
|
|
100
118
|
* Decide whether a pre-flight config blocks a tool call. Returns the denial
|
|
101
119
|
* reason, or null when the call is allowed. The artifact path itself is
|
|
@@ -133,6 +151,8 @@ export interface CompletionDeps {
|
|
|
133
151
|
/** Last-blocked-evaluation snapshots for no-progress early stand-down. */
|
|
134
152
|
stuckSnapshots: StuckSnapshotStore;
|
|
135
153
|
log: LogFn;
|
|
154
|
+
/** This session's `/df-ignore` additions (live `HookState.sessionIgnores`). */
|
|
155
|
+
sessionIgnores?: readonly string[];
|
|
136
156
|
/** Shared limiter bounding concurrent linter subprocesses. */
|
|
137
157
|
lintLimiter?: LintLimiter;
|
|
138
158
|
/** Session pass cache; skips redundant gate suites across idle boundaries. */
|
|
@@ -160,6 +180,12 @@ export interface InspectionDeps {
|
|
|
160
180
|
directory: string;
|
|
161
181
|
/** Read-only snapshot of tracker files; never mutated. */
|
|
162
182
|
trackerFiles: string[];
|
|
183
|
+
/**
|
|
184
|
+
* This session's `/df-ignore` additions (live `HookState.sessionIgnores`).
|
|
185
|
+
* Unioned with config `gate.ignore` at the merge point; absent reads as
|
|
186
|
+
* no session additions.
|
|
187
|
+
*/
|
|
188
|
+
sessionIgnores?: readonly string[];
|
|
163
189
|
/** Shared limiter bounding concurrent linter subprocesses. */
|
|
164
190
|
lintLimiter?: LintLimiter;
|
|
165
191
|
/**
|
package/dist/core/harness.js
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
* synthetic continuation) and the `session.idle` event net (re-prompt).
|
|
18
18
|
*/
|
|
19
19
|
import { readFile, stat } from "node:fs/promises";
|
|
20
|
-
import { isAbsolute, join, normalize, relative } from "node:path";
|
|
20
|
+
import { basename, isAbsolute, join, normalize, relative } from "node:path";
|
|
21
|
+
import { compileGlobMatchers } from "./command-utils.js";
|
|
21
22
|
import { runGate, summarizeGate } from "./gate.js";
|
|
22
23
|
import { LEGACY_PREFLIGHT_ARTIFACT_REL, LEGACY_REVIEW_ARTIFACT_REL, PREFLIGHT_ARTIFACT_REL, REVIEW_ARTIFACT_REL, REVIEW_RELS, RUNTIME_STATUS_RELS, } from "./paths.js";
|
|
23
24
|
import { assessReviewContent, findUncoveredFiles, normalizeReviewPath, staleReviewMessage, templateReviewMessage, thinReviewMessage, } from "./review.js";
|
|
@@ -228,6 +229,48 @@ export async function gitChangedFiles(run, cwd) {
|
|
|
228
229
|
export function mergeChangedFiles(trackerFiles, gitFiles) {
|
|
229
230
|
return [...new Set([...trackerFiles, ...gitFiles])].sort();
|
|
230
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Match a file path against the gate-ignore patterns: permanent config
|
|
234
|
+
* (`gate.ignore`) plus this session's `/df-ignore` additions. Returns the
|
|
235
|
+
* matching pattern, or undefined. Mirrors `matchExclude` semantics — paths
|
|
236
|
+
* resolve against the project directory, and patterns without a slash also
|
|
237
|
+
* match basenames at any depth. Matchers compile once per pattern array via
|
|
238
|
+
* the shared `compileGlobMatchers` cache, so callers pass the live arrays
|
|
239
|
+
* (never a spread copy) to keep the cache hot.
|
|
240
|
+
*/
|
|
241
|
+
export function matchGateIgnore(config, sessionIgnores, filePath, directory) {
|
|
242
|
+
let candidate = filePath;
|
|
243
|
+
if (directory !== undefined && isAbsolute(filePath)) {
|
|
244
|
+
candidate = relative(directory, filePath);
|
|
245
|
+
}
|
|
246
|
+
candidate = candidate.replace(/^\.\//, "");
|
|
247
|
+
const name = basename(candidate);
|
|
248
|
+
const sources = [config.gate.ignore, sessionIgnores];
|
|
249
|
+
for (const patterns of sources) {
|
|
250
|
+
for (const { pattern, match } of compileGlobMatchers(patterns)) {
|
|
251
|
+
if (match(candidate)) {
|
|
252
|
+
return pattern;
|
|
253
|
+
}
|
|
254
|
+
if (!pattern.includes("/") && match(name)) {
|
|
255
|
+
return pattern;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Drop gate-ignored files from a changed-file list. Applied once at the
|
|
263
|
+
* `inspectCompletion` merge point so ignored files leave the whole gate:
|
|
264
|
+
* command steps, review coverage, and the pass-cache fingerprint all read
|
|
265
|
+
* the filtered list. Session additions and permanent config filter
|
|
266
|
+
* identically — permanence differs, behavior does not.
|
|
267
|
+
*/
|
|
268
|
+
export function filterGateIgnored(config, sessionIgnores, files, directory) {
|
|
269
|
+
if (config.gate.ignore.length === 0 && sessionIgnores.length === 0) {
|
|
270
|
+
return files;
|
|
271
|
+
}
|
|
272
|
+
return files.filter((f) => matchGateIgnore(config, sessionIgnores, f, directory) === undefined);
|
|
273
|
+
}
|
|
231
274
|
/**
|
|
232
275
|
* Decide whether a pre-flight config blocks a tool call. Returns the denial
|
|
233
276
|
* reason, or null when the call is allowed. The artifact path itself is
|
|
@@ -379,7 +422,9 @@ export async function inspectCompletion(deps) {
|
|
|
379
422
|
return disabled;
|
|
380
423
|
}
|
|
381
424
|
const gitFiles = await gitChangedFiles(run, directory);
|
|
382
|
-
|
|
425
|
+
// Gate-ignore hotlist: ignored files leave the whole gate — steps, review
|
|
426
|
+
// coverage, and the fingerprint below all read this filtered list.
|
|
427
|
+
const changedFiles = filterGateIgnored(config, deps.sessionIgnores ?? [], mergeChangedFiles(trackerFiles, gitFiles), directory);
|
|
383
428
|
if (config.gate.skip_unchanged && changedFiles.length === 0) {
|
|
384
429
|
return {
|
|
385
430
|
...disabled,
|
|
@@ -496,6 +541,7 @@ export async function evaluateCompletion(deps) {
|
|
|
496
541
|
config,
|
|
497
542
|
directory,
|
|
498
543
|
trackerFiles: tracker.getChangedFiles(),
|
|
544
|
+
sessionIgnores: deps.sessionIgnores ?? [],
|
|
499
545
|
lintLimiter: deps.lintLimiter,
|
|
500
546
|
passCache: deps.passCache,
|
|
501
547
|
baseline: deps.baseline,
|
package/dist/core/install-dsh.js
CHANGED
|
@@ -16,7 +16,7 @@ export const ODF_MANAGED_END = "# END odf-gates";
|
|
|
16
16
|
/** Seams every profile provides. `agentPresets` joins only where detected. */
|
|
17
17
|
export const ODF_BASE_SEAMS = ["tools", "goals", "approval", "subagents"];
|
|
18
18
|
export function resolveDshHome(explicit) {
|
|
19
|
-
const fromEnv = process.env
|
|
19
|
+
const fromEnv = process.env.DSH_HOME;
|
|
20
20
|
return (explicit ?? (typeof fromEnv === "string" && fromEnv !== "" ? fromEnv : join(homedir(), ".dsh")));
|
|
21
21
|
}
|
|
22
22
|
/** Probe one composed dump for preset-registry presence AND an
|
package/dist/core/installer.d.ts
CHANGED
|
@@ -150,3 +150,15 @@ export declare function formatWizardBrief(brief: WizardBrief): string[];
|
|
|
150
150
|
* instead of re-serializing the YAML so user comments and formatting survive.
|
|
151
151
|
*/
|
|
152
152
|
export declare function setProfileInFile(configPath: string, profile: Profile): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Persist gate-ignore patterns to a config file, shape-aware: flat files
|
|
155
|
+
* grow the `gate_ignore:` line, native files grow the `gate: ignore:`
|
|
156
|
+
* sequence, scalar-only files (e.g. just `profile:`) gain a flat line,
|
|
157
|
+
* and JSON files (native-only by design) grow `gate.ignore`. A missing
|
|
158
|
+
* file is created flat. `parseDocument` round-trips the YAML so user
|
|
159
|
+
* comments and formatting survive outside the edited node. Returns the
|
|
160
|
+
* patterns newly stored (already-present ones are skipped, never
|
|
161
|
+
* duplicated). Throws a readable error when the file exists but the
|
|
162
|
+
* `gate:` value is not a mapping.
|
|
163
|
+
*/
|
|
164
|
+
export declare function storeGateIgnores(configPath: string, patterns: string[]): Promise<string[]>;
|
package/dist/core/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 { createInterface } from "node:readline";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { isMap, isScalar, isSeq, parseDocument } from "yaml";
|
|
5
6
|
import { splitCommand } from "./command-utils.js";
|
|
6
7
|
import { checkConfigEnforceable, DEFAULT_PROTECT, existingConfigPath, resolveConfig, } from "./config.js";
|
|
7
8
|
import { detectProject } from "./detect.js";
|
|
@@ -592,3 +593,143 @@ export async function setProfileInFile(configPath, profile) {
|
|
|
592
593
|
}
|
|
593
594
|
await fs.writeFile(configPath, content, "utf8");
|
|
594
595
|
}
|
|
596
|
+
/** Read a raw YAML/JSON value as a pattern list: strings split on
|
|
597
|
+
* whitespace (flat `gate_ignore: "a b"` form), sequences as-is, anything
|
|
598
|
+
* else as empty. YAML nodes arrive as `Seq`, not plain arrays — both are
|
|
599
|
+
* handled. */
|
|
600
|
+
function toPatternList(value) {
|
|
601
|
+
if (typeof value === "string") {
|
|
602
|
+
return value.split(/\s+/).filter((p) => p !== "");
|
|
603
|
+
}
|
|
604
|
+
const items = isSeq(value) ? value.items : Array.isArray(value) ? value : null;
|
|
605
|
+
if (items === null) {
|
|
606
|
+
return [];
|
|
607
|
+
}
|
|
608
|
+
return items
|
|
609
|
+
.map((item) => (isScalar(item) ? String(item.value) : String(item)))
|
|
610
|
+
.filter((p) => p !== "");
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Persist gate-ignore patterns to a config file, shape-aware: flat files
|
|
614
|
+
* grow the `gate_ignore:` line, native files grow the `gate: ignore:`
|
|
615
|
+
* sequence, scalar-only files (e.g. just `profile:`) gain a flat line,
|
|
616
|
+
* and JSON files (native-only by design) grow `gate.ignore`. A missing
|
|
617
|
+
* file is created flat. `parseDocument` round-trips the YAML so user
|
|
618
|
+
* comments and formatting survive outside the edited node. Returns the
|
|
619
|
+
* patterns newly stored (already-present ones are skipped, never
|
|
620
|
+
* duplicated). Throws a readable error when the file exists but the
|
|
621
|
+
* `gate:` value is not a mapping.
|
|
622
|
+
*/
|
|
623
|
+
export async function storeGateIgnores(configPath, patterns) {
|
|
624
|
+
const fresh = patterns.map((p) => p.trim()).filter((p) => p !== "");
|
|
625
|
+
if (fresh.length === 0) {
|
|
626
|
+
return [];
|
|
627
|
+
}
|
|
628
|
+
if (configPath.endsWith(".json")) {
|
|
629
|
+
return storeGateIgnoresJson(configPath, fresh);
|
|
630
|
+
}
|
|
631
|
+
let text = "";
|
|
632
|
+
try {
|
|
633
|
+
text = await fs.readFile(configPath, "utf8");
|
|
634
|
+
}
|
|
635
|
+
catch {
|
|
636
|
+
// File does not exist yet; it will be created below.
|
|
637
|
+
}
|
|
638
|
+
const doc = parseDocument(text);
|
|
639
|
+
if (doc.contents !== null && !isMap(doc.contents)) {
|
|
640
|
+
throw new Error(`Cannot store gate ignores in ${configPath}: root is not a mapping.`);
|
|
641
|
+
}
|
|
642
|
+
const added = [];
|
|
643
|
+
const union = (existing) => {
|
|
644
|
+
for (const p of fresh) {
|
|
645
|
+
if (!existing.includes(p)) {
|
|
646
|
+
existing.push(p);
|
|
647
|
+
added.push(p);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return existing;
|
|
651
|
+
};
|
|
652
|
+
// Same sniffing as `selectConfigRecord`: native-only keys (with
|
|
653
|
+
// non-null values — the loader filters nulls, so `doc.has` alone would
|
|
654
|
+
// over-count commented-out debris) or object-form `rules:` mean native
|
|
655
|
+
// shape, so a new key must not introduce a flat line (which the loader
|
|
656
|
+
// would reject as mixed-shape).
|
|
657
|
+
const hasNativeKeys = doc.contents !== null &&
|
|
658
|
+
(["commands", "gate", "on_edit"].some((key) => hasLiveKey(doc, key)) ||
|
|
659
|
+
isMap(doc.get("rules", true)));
|
|
660
|
+
if (!hasNativeKeys) {
|
|
661
|
+
// Flat shape: values are space-separated on one line, so patterns
|
|
662
|
+
// with spaces cannot round-trip — fail loudly instead of silently
|
|
663
|
+
// storing two bogus patterns.
|
|
664
|
+
const spaced = fresh.filter((p) => /\s/.test(p));
|
|
665
|
+
if (spaced.length > 0) {
|
|
666
|
+
throw new Error(`Cannot store ${spaced.join(", ")} in ${configPath}: flat-shape ignores are ` +
|
|
667
|
+
`space-separated. Convert the config to native shape (a gate: ignore: list) first.`);
|
|
668
|
+
}
|
|
669
|
+
if (doc.has("gate_ignore")) {
|
|
670
|
+
doc.set("gate_ignore", union(toPatternList(doc.get("gate_ignore"))).join(" "));
|
|
671
|
+
}
|
|
672
|
+
else {
|
|
673
|
+
doc.set("gate_ignore", fresh.join(" "));
|
|
674
|
+
added.push(...fresh);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
// Null-valued `gate:` counts as absent (the loader filters nulls) —
|
|
679
|
+
// only a non-null non-mapping gate is a real error.
|
|
680
|
+
const gate = doc.get("gate", true);
|
|
681
|
+
if (gate === undefined || gate === null || (isScalar(gate) && gate.value == null)) {
|
|
682
|
+
doc.set("gate", { ignore: union([]) });
|
|
683
|
+
}
|
|
684
|
+
else if (!isMap(gate)) {
|
|
685
|
+
throw new Error(`Cannot store gate ignores in ${configPath}: gate: is not a mapping.`);
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
gate.set("ignore", union(toPatternList(gate.get("ignore"))));
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
await fs.writeFile(configPath, String(doc), "utf8");
|
|
692
|
+
return added;
|
|
693
|
+
}
|
|
694
|
+
/** A key the loader's shape sniffing would count: present with a
|
|
695
|
+
* non-null value (`doc.has` alone counts commented-out `key:` debris). */
|
|
696
|
+
function hasLiveKey(doc, key) {
|
|
697
|
+
const node = doc.get(key, true);
|
|
698
|
+
return node !== undefined && node !== null && !(isScalar(node) && node.value == null);
|
|
699
|
+
}
|
|
700
|
+
async function storeGateIgnoresJson(configPath, fresh) {
|
|
701
|
+
let obj = {};
|
|
702
|
+
try {
|
|
703
|
+
const text = await fs.readFile(configPath, "utf8");
|
|
704
|
+
const parsed = JSON.parse(text);
|
|
705
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
706
|
+
throw new Error(`Cannot store gate ignores in ${configPath}: root is not an object.`);
|
|
707
|
+
}
|
|
708
|
+
obj = parsed;
|
|
709
|
+
}
|
|
710
|
+
catch (error) {
|
|
711
|
+
if (error?.code !== "ENOENT") {
|
|
712
|
+
throw error;
|
|
713
|
+
}
|
|
714
|
+
// File does not exist yet; it will be created below.
|
|
715
|
+
}
|
|
716
|
+
const added = [];
|
|
717
|
+
let gate;
|
|
718
|
+
if (typeof obj.gate === "object" && obj.gate !== null && !Array.isArray(obj.gate)) {
|
|
719
|
+
gate = obj.gate;
|
|
720
|
+
}
|
|
721
|
+
else {
|
|
722
|
+
gate = {};
|
|
723
|
+
obj.gate = gate;
|
|
724
|
+
}
|
|
725
|
+
const current = Array.isArray(gate.ignore) ? gate.ignore.map((item) => String(item)) : [];
|
|
726
|
+
for (const p of fresh) {
|
|
727
|
+
if (!current.includes(p)) {
|
|
728
|
+
current.push(p);
|
|
729
|
+
added.push(p);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
gate.ignore = current;
|
|
733
|
+
await fs.writeFile(configPath, `${JSON.stringify(obj, null, 2)}\n`, "utf8");
|
|
734
|
+
return added;
|
|
735
|
+
}
|
package/dist/core/logger.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Structured logging wrapper.
|
|
2
|
+
* Structured logging wrapper. Logs to stderr and the user-level log file.
|
|
3
3
|
*/
|
|
4
4
|
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
5
5
|
export declare const LOG_SERVICE = "opencode-dev-framework";
|
|
@@ -13,18 +13,6 @@ export declare const LOG_FILE_NAME = "opencode-dev-framework.log";
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const MAX_LOG_BYTES: number;
|
|
15
15
|
export type LogFn = (level: LogLevel, message: string, extra?: Record<string, unknown>) => Promise<void>;
|
|
16
|
-
type V1Client = {
|
|
17
|
-
app?: {
|
|
18
|
-
log?: (args: {
|
|
19
|
-
body: {
|
|
20
|
-
service: string;
|
|
21
|
-
level: LogLevel;
|
|
22
|
-
message: string;
|
|
23
|
-
extra?: Record<string, unknown>;
|
|
24
|
-
};
|
|
25
|
-
}) => Promise<unknown>;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
16
|
export interface LogPathInput {
|
|
29
17
|
platform?: string;
|
|
30
18
|
env?: Record<string, string | undefined>;
|
|
@@ -48,12 +36,6 @@ export declare function resolveDefaultLogFile(input?: LogPathInput): string | nu
|
|
|
48
36
|
*/
|
|
49
37
|
export declare function rotateLogFile(filePath: string, maxBytes: number): Promise<void>;
|
|
50
38
|
/**
|
|
51
|
-
* Create a logger.
|
|
52
|
-
* (as tests expect). Otherwise logs to stderr/file (V2 runtime).
|
|
39
|
+
* Create a logger. Writes to stderr and the user-level log file.
|
|
53
40
|
*/
|
|
54
|
-
export declare function createLogger(
|
|
55
|
-
app: {
|
|
56
|
-
log: (...args: unknown[]) => Promise<unknown>;
|
|
57
|
-
};
|
|
58
|
-
}): LogFn;
|
|
59
|
-
export {};
|
|
41
|
+
export declare function createLogger(): LogFn;
|
package/dist/core/logger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Structured logging wrapper.
|
|
2
|
+
* Structured logging wrapper. Logs to stderr and the user-level log file.
|
|
3
3
|
*/
|
|
4
4
|
import { appendFile, mkdir, rename, rm, stat } from "node:fs/promises";
|
|
5
5
|
import { homedir, tmpdir } from "node:os";
|
|
@@ -126,10 +126,9 @@ export async function rotateLogFile(filePath, maxBytes) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
|
-
* Create a logger.
|
|
130
|
-
* (as tests expect). Otherwise logs to stderr/file (V2 runtime).
|
|
129
|
+
* Create a logger. Writes to stderr and the user-level log file.
|
|
131
130
|
*/
|
|
132
|
-
export function createLogger(
|
|
131
|
+
export function createLogger() {
|
|
133
132
|
// Explicit override wins (empty string disables file logging:
|
|
134
133
|
// the falsy filePath below skips all writes); otherwise a
|
|
135
134
|
// user-level default so the "loud" record exists without
|
|
@@ -147,26 +146,6 @@ export function createLogger(client) {
|
|
|
147
146
|
message,
|
|
148
147
|
extra,
|
|
149
148
|
});
|
|
150
|
-
if (client?.app?.log) {
|
|
151
|
-
try {
|
|
152
|
-
// biome-ignore lint/style/noNonNullAssertion: guarded by if above
|
|
153
|
-
await client.app.log({
|
|
154
|
-
body: { service: LOG_SERVICE, level, message, extra },
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
catch (error) {
|
|
158
|
-
try {
|
|
159
|
-
process.stderr.write(`[${LOG_SERVICE}] ${level} ${message} (app.log failed: ${String(error)})\n`);
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
// ignore
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (filePath) {
|
|
166
|
-
await appendLogFile(filePath, line);
|
|
167
|
-
}
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
149
|
try {
|
|
171
150
|
process.stderr.write(`[${LOG_SERVICE}] ${level} ${message}\n`);
|
|
172
151
|
if (extra && Object.keys(extra).length > 0) {
|
package/dist/core/run-hooks.d.ts
CHANGED
|
@@ -60,6 +60,13 @@ export interface HookState {
|
|
|
60
60
|
lintLimiter: LintLimiter;
|
|
61
61
|
/** Fingerprint of the last clean gate pass; skips redundant suites. */
|
|
62
62
|
passCache: PassCache;
|
|
63
|
+
/**
|
|
64
|
+
* This session's gate-ignore hotlist (`/df-ignore` additions, bare form).
|
|
65
|
+
* Session-scoped by design: permanence is an explicit act (`-s|--store`
|
|
66
|
+
* writes config instead). Mutated in place so the shared glob-matcher
|
|
67
|
+
* cache stays hot; read at every gate evaluation via `runCompletion`.
|
|
68
|
+
*/
|
|
69
|
+
sessionIgnores: string[];
|
|
63
70
|
/**
|
|
64
71
|
* Host seam availability (see `HostSeams`), probed once at mount with
|
|
65
72
|
* guarded reads. Rendered by status so a degraded mount reads as
|
package/dist/core/run-hooks.js
CHANGED
|
@@ -154,6 +154,7 @@ export function runCompletion(state, sessionID) {
|
|
|
154
154
|
tracker: state.tracker,
|
|
155
155
|
blockCounts: state.blocks,
|
|
156
156
|
stuckSnapshots: state.stuckSnapshots,
|
|
157
|
+
sessionIgnores: state.sessionIgnores,
|
|
157
158
|
lintLimiter: state.lintLimiter,
|
|
158
159
|
passCache: state.passCache,
|
|
159
160
|
baseline: state.initialEnforceable,
|