opencode-dev-framework 1.9.2 → 1.9.4
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/dist/index.js +14 -5
- package/dist/registry.d.ts +14 -0
- package/dist/registry.js +34 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ import { runCommand } from "./host.js";
|
|
|
36
36
|
import { createLintLimiter, detectPreCommitAvailability, isLintFailure, lintFile, summarizeLint, } from "./lint.js";
|
|
37
37
|
import { createLogger } from "./logger.js";
|
|
38
38
|
import { checkToolCall, extractCommand, extractFilePath, extractRedirectTargets, FILE_TOOLS, SHELL_TOOLS, toPermissionGuard, } from "./protect.js";
|
|
39
|
-
import { clearSessionDirectory, hasSeenSessionStart, markSessionStartSeen, resolveIsChildSession, } from "./registry.js";
|
|
39
|
+
import { clearSessionDirectory, hasSeenSessionStart, markSessionStartSeen, resolveIsChildSession, resolveSessionDepth, } from "./registry.js";
|
|
40
40
|
import { findRosterIndex, renderDutyRoster, rosterPresent } from "./roster.js";
|
|
41
41
|
import { constitutionPresent, loadConstitution } from "./rules.js";
|
|
42
42
|
import { writeRuntimeStatus } from "./runtime-status.js";
|
|
@@ -476,8 +476,14 @@ const plugin = Plugin.define({
|
|
|
476
476
|
// a dirty tree must never be blocked or told to write it. Skip
|
|
477
477
|
// before any gate work; both levers share this predicate.
|
|
478
478
|
if (await resolveIsChildSession(sessionID, sessionGetter)) {
|
|
479
|
+
// Tripwire (plan 24): log the chain depth on every child-gated
|
|
480
|
+
// decision. Depth 1 is the entire world at core's default
|
|
481
|
+
// `experimental.subagent_depth`; anything deeper means nesting
|
|
482
|
+
// arrived via a raised limit or a non-tool creation path.
|
|
483
|
+
const depth = await resolveSessionDepth(sessionID, sessionGetter);
|
|
479
484
|
await safeLog(state, "debug", "completion gate skipped: child session owes no review duty", {
|
|
480
485
|
sessionID,
|
|
486
|
+
depth,
|
|
481
487
|
});
|
|
482
488
|
return;
|
|
483
489
|
}
|
|
@@ -627,13 +633,14 @@ const plugin = Plugin.define({
|
|
|
627
633
|
const childID = typeof event.sessionID === "string" ? event.sessionID : "";
|
|
628
634
|
if (await resolveIsChildSession(childID, sessionGetter)) {
|
|
629
635
|
const reason = childArtifactDenial();
|
|
636
|
+
const depth = await resolveSessionDepth(childID, sessionGetter);
|
|
630
637
|
if (state.config.profile === "advisory") {
|
|
631
|
-
await safeLog(state, "debug", reason, { ...baseExtra });
|
|
638
|
+
await safeLog(state, "debug", reason, { ...baseExtra, depth });
|
|
632
639
|
}
|
|
633
640
|
else {
|
|
634
641
|
event.effect = "deny";
|
|
635
642
|
event.message = reason;
|
|
636
|
-
await safeLog(state, "error", reason, { ...baseExtra });
|
|
643
|
+
await safeLog(state, "error", reason, { ...baseExtra, depth });
|
|
637
644
|
}
|
|
638
645
|
return;
|
|
639
646
|
}
|
|
@@ -697,7 +704,8 @@ const plugin = Plugin.define({
|
|
|
697
704
|
const childID = typeof sessionID === "string" ? sessionID : "";
|
|
698
705
|
if (await resolveIsChildSession(childID, sessionGetter)) {
|
|
699
706
|
const reason = childArtifactDenial();
|
|
700
|
-
const
|
|
707
|
+
const depth = await resolveSessionDepth(childID, sessionGetter);
|
|
708
|
+
const extra = { tool: toolName, sessionID, depth };
|
|
701
709
|
if (state.config.profile === "advisory") {
|
|
702
710
|
await safeLog(state, "warn", reason, extra);
|
|
703
711
|
}
|
|
@@ -1137,7 +1145,8 @@ const plugin = Plugin.define({
|
|
|
1137
1145
|
// Same child-session skip as the hook lever above: no duty, no
|
|
1138
1146
|
// verdict, no re-prompt — the parent answers for the tree.
|
|
1139
1147
|
if (await resolveIsChildSession(sessionID, sessionGetter)) {
|
|
1140
|
-
|
|
1148
|
+
const depth = await resolveSessionDepth(sessionID, sessionGetter);
|
|
1149
|
+
await safeLog(state, "debug", "completion gate skipped: child session owes no review duty", { sessionID, depth });
|
|
1141
1150
|
continue;
|
|
1142
1151
|
}
|
|
1143
1152
|
// The §1b hook completed an evaluation for this boundary — one
|
package/dist/registry.d.ts
CHANGED
|
@@ -57,6 +57,20 @@ export interface SessionParentInfo {
|
|
|
57
57
|
* gated and may write, as before. Never throws.
|
|
58
58
|
*/
|
|
59
59
|
export declare function resolveIsChildSession(sessionID: string, getSession?: (id: string) => Promise<SessionParentInfo | null | undefined>): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Best-effort session-tree depth for the plan-24 tripwire: the number of
|
|
62
|
+
* `parentID` hops from the session to its top-level root (0 = top-level).
|
|
63
|
+
* Logged on child-gated decisions so the first real nesting shows up in
|
|
64
|
+
* the log instead of passing silently. Uncapped by policy — the visited
|
|
65
|
+
* set only guards against a pathological cycle, which the core API cannot
|
|
66
|
+
* currently produce (no `parentID` mutation; creation with an unknown
|
|
67
|
+
* parent is rejected). Never throws and never caches: an empty sessionID
|
|
68
|
+
* or missing getter yields null (unknown), any lookup failure abandons
|
|
69
|
+
* the walk and yields null rather than a misleading partial count, and
|
|
70
|
+
* the call sites are rare (idle boundaries, artifact writes) so
|
|
71
|
+
* freshness beats memoization.
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveSessionDepth(sessionID: string, getSession?: (id: string) => Promise<SessionParentInfo | null | undefined>): Promise<number | null>;
|
|
60
74
|
export declare function setSessionDirectory(sessionID: string, directory: string): void;
|
|
61
75
|
export declare function getDirectoryForSession(sessionID: string): string | null;
|
|
62
76
|
/** Forget a session's directory mapping (called on `session.deleted`). */
|
package/dist/registry.js
CHANGED
|
@@ -88,6 +88,40 @@ export async function resolveIsChildSession(sessionID, getSession) {
|
|
|
88
88
|
return false;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Best-effort session-tree depth for the plan-24 tripwire: the number of
|
|
93
|
+
* `parentID` hops from the session to its top-level root (0 = top-level).
|
|
94
|
+
* Logged on child-gated decisions so the first real nesting shows up in
|
|
95
|
+
* the log instead of passing silently. Uncapped by policy — the visited
|
|
96
|
+
* set only guards against a pathological cycle, which the core API cannot
|
|
97
|
+
* currently produce (no `parentID` mutation; creation with an unknown
|
|
98
|
+
* parent is rejected). Never throws and never caches: an empty sessionID
|
|
99
|
+
* or missing getter yields null (unknown), any lookup failure abandons
|
|
100
|
+
* the walk and yields null rather than a misleading partial count, and
|
|
101
|
+
* the call sites are rare (idle boundaries, artifact writes) so
|
|
102
|
+
* freshness beats memoization.
|
|
103
|
+
*/
|
|
104
|
+
export async function resolveSessionDepth(sessionID, getSession) {
|
|
105
|
+
if (sessionID === "" || getSession === undefined)
|
|
106
|
+
return null;
|
|
107
|
+
const seen = new Set([sessionID]);
|
|
108
|
+
let depth = 0;
|
|
109
|
+
let current = sessionID;
|
|
110
|
+
try {
|
|
111
|
+
while (true) {
|
|
112
|
+
const parent = (await getSession(current))?.parentID;
|
|
113
|
+
if (typeof parent !== "string" || parent === "" || seen.has(parent))
|
|
114
|
+
break;
|
|
115
|
+
seen.add(parent);
|
|
116
|
+
depth++;
|
|
117
|
+
current = parent;
|
|
118
|
+
}
|
|
119
|
+
return depth;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
91
125
|
export function setSessionDirectory(sessionID, directory) {
|
|
92
126
|
sessionToDirectory.set(sessionID, directory);
|
|
93
127
|
}
|