github-router 0.3.348 → 0.3.350
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/{aic-statusline-settings-YoDG20pq.js → aic-statusline-settings-DCFywz3N.js} +2 -2
- package/dist/aic-statusline-settings-DCFywz3N.js.map +1 -0
- package/dist/{attribution-settings-P_vba-ri.js → attribution-settings-B9T-EsEs.js} +80 -12
- package/dist/attribution-settings-B9T-EsEs.js.map +1 -0
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/{claude-D26fp1ih.js → claude-BY4e9ueE.js} +29 -14
- package/dist/{claude-D26fp1ih.js.map → claude-BY4e9ueE.js.map} +1 -1
- package/dist/{codex-DM97sCtu.js → codex-BOugL-uX.js} +4 -4
- package/dist/{codex-DM97sCtu.js.map → codex-BOugL-uX.js.map} +1 -1
- package/dist/engine-DZfLaVcf.js +2 -0
- package/dist/{gate-discovery-V-mslLHt.js → gate-discovery-BFqulsWz.js} +4 -4
- package/dist/{gate-discovery-V-mslLHt.js.map → gate-discovery-BFqulsWz.js.map} +1 -1
- package/dist/hooks.mjs +1101 -71
- package/dist/hooks.sha256 +1 -1
- package/dist/{internal-aic-status-CCvU7zhC.js → internal-aic-status-lM0YNDaH.js} +52 -11
- package/dist/internal-aic-status-lM0YNDaH.js.map +1 -0
- package/dist/{internal-artifact-open-CXJbMXpq.js → internal-artifact-open-DErO3WpR.js} +2 -2
- package/dist/{internal-artifact-open-CXJbMXpq.js.map → internal-artifact-open-DErO3WpR.js.map} +1 -1
- package/dist/{internal-plan-review-F-WbltsT.js → internal-plan-review-DbX-mr9i.js} +3 -3
- package/dist/{internal-plan-review-F-WbltsT.js.map → internal-plan-review-DbX-mr9i.js.map} +1 -1
- package/dist/internal-prompt-submit-CA5Y4DWM.js +2 -0
- package/dist/internal-prompt-submit-UhfnM_qG.js +573 -0
- package/dist/internal-prompt-submit-UhfnM_qG.js.map +1 -0
- package/dist/internal-rebrief-BH9PMJhF.js +548 -0
- package/dist/internal-rebrief-BH9PMJhF.js.map +1 -0
- package/dist/{internal-session-bind-LrYEo-kg.js → internal-session-bind-DxdVbJ7x.js} +2 -2
- package/dist/{internal-session-bind-LrYEo-kg.js.map → internal-session-bind-DxdVbJ7x.js.map} +1 -1
- package/dist/{internal-stop-hook-v5WF6Kc2.js → internal-stop-hook-DlGc9WwJ.js} +5 -5
- package/dist/{internal-stop-hook-v5WF6Kc2.js.map → internal-stop-hook-DlGc9WwJ.js.map} +1 -1
- package/dist/{internal-stop-review-nL003JIj.js → internal-stop-review-CORT3UGr.js} +2 -2
- package/dist/{internal-stop-review-nL003JIj.js.map → internal-stop-review-CORT3UGr.js.map} +1 -1
- package/dist/main.js +14 -13
- package/dist/main.js.map +1 -1
- package/dist/{orchestration-DjuJRhXn.js → orchestration-Dkqv-iv0.js} +2 -2
- package/dist/{orchestration-DjuJRhXn.js.map → orchestration-Dkqv-iv0.js.map} +1 -1
- package/dist/{peer-mcp-personas-C200IycG.js → peer-mcp-personas-BwwSNnBC.js} +235 -63
- package/dist/peer-mcp-personas-BwwSNnBC.js.map +1 -0
- package/dist/{pi-BWGfNpi7.js → pi-Dpw8Otxw.js} +5 -5
- package/dist/{pi-BWGfNpi7.js.map → pi-Dpw8Otxw.js.map} +1 -1
- package/dist/{plan-review-hook-DMqPHBBN.js → plan-review-hook-LfG01VMp.js} +2 -2
- package/dist/{plan-review-hook-DMqPHBBN.js.map → plan-review-hook-LfG01VMp.js.map} +1 -1
- package/dist/{prompt-submit-hook-wjuHUrpS.js → prompt-submit-hook-DzhmQRs_.js} +130 -45
- package/dist/prompt-submit-hook-DzhmQRs_.js.map +1 -0
- package/dist/{provision-BFTONLfA.js → provision-9TAIgyL7.js} +2 -2
- package/dist/{provision-BFTONLfA.js.map → provision-9TAIgyL7.js.map} +1 -1
- package/dist/{serve-D9xQeGqi.js → serve-BRKRWkd1.js} +8 -8
- package/dist/{serve-D9xQeGqi.js.map → serve-BRKRWkd1.js.map} +1 -1
- package/dist/{server-setup-R1HQtpR9.js → server-setup-DXVFE7bf.js} +25 -14
- package/dist/server-setup-DXVFE7bf.js.map +1 -0
- package/dist/{start-vg2n8UjI.js → start-CoR3jqUR.js} +3 -3
- package/dist/{start-vg2n8UjI.js.map → start-CoR3jqUR.js.map} +1 -1
- package/dist/{stop-gate-hook-DRcYQAtf.js → stop-gate-hook-C9VNxmt1.js} +2 -2
- package/dist/{stop-gate-hook-DRcYQAtf.js.map → stop-gate-hook-C9VNxmt1.js.map} +1 -1
- package/dist/{stop-gate-policy-CbLklfV2.js → stop-gate-policy-DQsfjnsx.js} +29 -2
- package/dist/{stop-gate-policy-CbLklfV2.js.map → stop-gate-policy-DQsfjnsx.js.map} +1 -1
- package/package.json +1 -1
- package/dist/aic-statusline-settings-YoDG20pq.js.map +0 -1
- package/dist/attribution-settings-P_vba-ri.js.map +0 -1
- package/dist/engine-VTQo0qUy.js +0 -2
- package/dist/internal-aic-status-CCvU7zhC.js.map +0 -1
- package/dist/internal-prompt-submit-B1nd4y4V.js +0 -213
- package/dist/internal-prompt-submit-B1nd4y4V.js.map +0 -1
- package/dist/peer-mcp-personas-C200IycG.js.map +0 -1
- package/dist/prompt-submit-hook-wjuHUrpS.js.map +0 -1
- package/dist/server-setup-R1HQtpR9.js.map +0 -1
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
import { i as parseBoolEnv } from "./exec-MCU1H-KZ.js";
|
|
2
|
+
import { f as stopReviewStateDir, i as fileRebriefBindingStore, n as fileFindingsStore, r as fileLastPromptStore, s as isSubagentContext } from "./stop-gate-policy-DQsfjnsx.js";
|
|
3
|
+
import { n as callMcpTool, r as hookMcpRuntimeFromEnv, t as callInference } from "./hook-mcp-client-BRL_y-bz.js";
|
|
4
|
+
import { a as getPromptSearchTip, d as buildRebriefSystem, f as isCheapestRewriteDisabledEnv, l as CHEAPEST_REWRITE_MODEL, o as isNonTrivialPrompt, p as runCheapestRewrite, s as CHEAPEST_REWRITE_EFFORT, t as PROMPT_STEER_GOAL } from "./prompt-submit-hook-DzhmQRs_.js";
|
|
5
|
+
import { t as buildStaticPack } from "./internal-prompt-submit-UhfnM_qG.js";
|
|
6
|
+
import { defineCommand } from "citty";
|
|
7
|
+
import { closeSync, existsSync, openSync, readFileSync, readSync, statSync } from "node:fs";
|
|
8
|
+
/** Char fallback when no tokenizer is available (~4 chars/token). */
|
|
9
|
+
const REBRIEF_MAX_CHARS = 16e3;
|
|
10
|
+
/**
|
|
11
|
+
* Extract one verbatim span from a Claude Code JSONL transcript line.
|
|
12
|
+
* Returns null when the line carries no usable text. Never throws.
|
|
13
|
+
*/
|
|
14
|
+
function extractTranscriptSpan(line) {
|
|
15
|
+
const trimmed = line.trim();
|
|
16
|
+
if (trimmed.length === 0) return null;
|
|
17
|
+
let obj;
|
|
18
|
+
try {
|
|
19
|
+
obj = JSON.parse(trimmed);
|
|
20
|
+
} catch {
|
|
21
|
+
return trimmed.length <= 280 ? {
|
|
22
|
+
text: trimmed.slice(0, 280),
|
|
23
|
+
priority: 4
|
|
24
|
+
} : null;
|
|
25
|
+
}
|
|
26
|
+
if (!obj || typeof obj !== "object" || Array.isArray(obj)) return null;
|
|
27
|
+
const rec = obj;
|
|
28
|
+
if (rec.parent_tool_use_id !== void 0 && rec.parent_tool_use_id !== null) return null;
|
|
29
|
+
if (rec.type === "result") {
|
|
30
|
+
const err = rec.is_error === true || typeof rec.status === "string" && rec.status.toLowerCase().includes("error");
|
|
31
|
+
const text = typeof rec.result === "string" ? rec.result : typeof rec.summary === "string" ? rec.summary : "";
|
|
32
|
+
if (text.trim().length === 0) return null;
|
|
33
|
+
return {
|
|
34
|
+
text: headLines(text.trim(), 40),
|
|
35
|
+
priority: err ? 1 : 4
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const msg = rec.message;
|
|
39
|
+
if (!msg || typeof msg !== "object" || Array.isArray(msg)) return null;
|
|
40
|
+
const m = msg;
|
|
41
|
+
const role = typeof m.role === "string" ? m.role : "unknown";
|
|
42
|
+
const content = m.content;
|
|
43
|
+
if (typeof content === "string") return content.trim().length > 0 ? {
|
|
44
|
+
text: headLines(content.trim(), 40),
|
|
45
|
+
priority: role === "user" ? 3 : 3
|
|
46
|
+
} : null;
|
|
47
|
+
if (!Array.isArray(content)) return null;
|
|
48
|
+
const spans = [];
|
|
49
|
+
for (const part of content) {
|
|
50
|
+
if (!part || typeof part !== "object") continue;
|
|
51
|
+
const b = part;
|
|
52
|
+
if (b.type === "text" && typeof b.text === "string" && b.text.trim().length > 0) spans.push({
|
|
53
|
+
text: b.text.trim(),
|
|
54
|
+
priority: 3
|
|
55
|
+
});
|
|
56
|
+
else if (b.type === "tool_use") {
|
|
57
|
+
const name = typeof b.name === "string" ? b.name : "?";
|
|
58
|
+
if (name === "Write" || name === "Edit") {
|
|
59
|
+
const serialized = JSON.stringify(b.input ?? {});
|
|
60
|
+
const inputObj = b.input ?? {};
|
|
61
|
+
const filePath = typeof inputObj.file_path === "string" ? inputObj.file_path : typeof inputObj.file === "string" ? inputObj.file : typeof inputObj.path === "string" ? inputObj.path : "";
|
|
62
|
+
const where = filePath ? ` ${filePath}` : "";
|
|
63
|
+
spans.push({
|
|
64
|
+
text: `[tool_use ${name}${where}: ~${serialized.length} chars elided (bulk input)]`,
|
|
65
|
+
priority: 5
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
const summary = summaryTools.has(name);
|
|
69
|
+
const input = JSON.stringify(b.input ?? {}).slice(0, summary ? 2e3 : 500);
|
|
70
|
+
spans.push({
|
|
71
|
+
text: `[tool_use ${name}: ${input}]`,
|
|
72
|
+
priority: summary ? 2 : 4
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
} else if (b.type === "tool_result") {
|
|
76
|
+
const raw = typeof b.content === "string" ? b.content : JSON.stringify(b.content ?? "");
|
|
77
|
+
const err = b.is_error === true;
|
|
78
|
+
spans.push({
|
|
79
|
+
text: `[tool_result${err ? " error=true" : ""}]:\n${headTail(raw.trim(), err ? 6e3 : 3e3)}`,
|
|
80
|
+
priority: err ? 1 : 4
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (spans.length === 0) return null;
|
|
85
|
+
spans.sort((a, b) => a.priority - b.priority);
|
|
86
|
+
const best = spans[0];
|
|
87
|
+
return {
|
|
88
|
+
text: headLines(spans.filter((s) => s.priority === best.priority).map((s) => s.text).join("\n"), 40),
|
|
89
|
+
priority: best.priority
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const summaryTools = /* @__PURE__ */ new Set([
|
|
93
|
+
"Task",
|
|
94
|
+
"Agent",
|
|
95
|
+
"WebFetch"
|
|
96
|
+
]);
|
|
97
|
+
function headLines(text, maxLines) {
|
|
98
|
+
const lines = text.split("\n");
|
|
99
|
+
if (lines.length <= maxLines) return text;
|
|
100
|
+
return `${lines.slice(0, maxLines).join("\n")}\n…[${lines.length - maxLines} lines elided]…`;
|
|
101
|
+
}
|
|
102
|
+
function headTail(text, maxChars) {
|
|
103
|
+
if (maxChars <= 0) return "";
|
|
104
|
+
if (text.length <= maxChars) return text;
|
|
105
|
+
const head = Math.floor(maxChars / 2);
|
|
106
|
+
const tail = maxChars - head;
|
|
107
|
+
return `${text.slice(0, head)}\n…[elided]…\n${text.slice(text.length - tail)}`;
|
|
108
|
+
}
|
|
109
|
+
/** Cap for the deterministic done-so-far digest (chars). */
|
|
110
|
+
const REBRIEF_DIGEST_MAX_CHARS = 2e3;
|
|
111
|
+
/**
|
|
112
|
+
* Deterministic "what has been done" digest from a transcript tail:
|
|
113
|
+
* extractive only, capped, never invents facts. Assistant text spans,
|
|
114
|
+
* tool names used, files mutated (Write/Edit path markers), and error
|
|
115
|
+
* results — the floor layer of the dual done-so-far. The Luna summary
|
|
116
|
+
* consult (Layer 2, produced by the command layer) sits on top of this.
|
|
117
|
+
*/
|
|
118
|
+
function buildDoneDigest(transcriptLines, maxChars = REBRIEF_DIGEST_MAX_CHARS) {
|
|
119
|
+
const parts = [];
|
|
120
|
+
const paths = /* @__PURE__ */ new Set();
|
|
121
|
+
const tools = /* @__PURE__ */ new Set();
|
|
122
|
+
const texts = [];
|
|
123
|
+
const errors = [];
|
|
124
|
+
for (const line of transcriptLines) {
|
|
125
|
+
const trimmed = line.trim();
|
|
126
|
+
if (trimmed.length === 0) continue;
|
|
127
|
+
let obj;
|
|
128
|
+
try {
|
|
129
|
+
obj = JSON.parse(trimmed);
|
|
130
|
+
} catch {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (!obj || typeof obj !== "object" || Array.isArray(obj)) continue;
|
|
134
|
+
const rec = obj;
|
|
135
|
+
if (rec.parent_tool_use_id !== void 0 && rec.parent_tool_use_id !== null) continue;
|
|
136
|
+
if (rec.type === "result") {
|
|
137
|
+
if (rec.is_error === true || typeof rec.status === "string" && rec.status.toLowerCase().includes("error")) errors.push(headTail(typeof rec.result === "string" ? rec.result : typeof rec.summary === "string" ? rec.summary : "", 400));
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const msg = rec.message;
|
|
141
|
+
if (!msg || typeof msg !== "object" || Array.isArray(msg)) continue;
|
|
142
|
+
const m = msg;
|
|
143
|
+
const role = typeof m.role === "string" ? m.role : "unknown";
|
|
144
|
+
const content = m.content;
|
|
145
|
+
if (role !== "assistant") continue;
|
|
146
|
+
if (typeof content === "string") {
|
|
147
|
+
if (content.trim().length > 0) texts.push(headLines(content.trim(), 8));
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (!Array.isArray(content)) continue;
|
|
151
|
+
for (const part of content) {
|
|
152
|
+
if (!part || typeof part !== "object") continue;
|
|
153
|
+
const b = part;
|
|
154
|
+
if (b.type === "text" && typeof b.text === "string" && b.text.trim().length > 0) texts.push(headLines(b.text.trim(), 8));
|
|
155
|
+
else if (b.type === "tool_use") {
|
|
156
|
+
const name = typeof b.name === "string" ? b.name : "?";
|
|
157
|
+
tools.add(name);
|
|
158
|
+
if (name === "Write" || name === "Edit") {
|
|
159
|
+
const inputObj = b.input ?? {};
|
|
160
|
+
const filePath = typeof inputObj.file_path === "string" ? inputObj.file_path : typeof inputObj.file === "string" ? inputObj.file : typeof inputObj.path === "string" ? inputObj.path : "";
|
|
161
|
+
if (filePath) paths.add(filePath);
|
|
162
|
+
}
|
|
163
|
+
} else if (b.type === "tool_result" && b.is_error === true) {
|
|
164
|
+
const raw = typeof b.content === "string" ? b.content : JSON.stringify(b.content ?? "");
|
|
165
|
+
errors.push(headTail(raw.trim(), 400));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (tools.size > 0) parts.push(`Tools used: ${[...tools].sort().join(", ")}`);
|
|
170
|
+
if (paths.size > 0) parts.push(`Files mutated: ${[...paths].sort().join(", ")}`);
|
|
171
|
+
if (errors.length > 0) parts.push(`Errors:\n${errors.join("\n---\n")}`);
|
|
172
|
+
if (texts.length > 0) parts.push(`Assistant text (recent):\n${texts.slice(-6).join("\n---\n")}`);
|
|
173
|
+
const joined = parts.join("\n\n");
|
|
174
|
+
return joined.length <= maxChars ? joined : `${joined.slice(0, maxChars).trimEnd()}\n…[digest truncated]…`;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Build the capped 4K rebrief context from a transcript tail.
|
|
178
|
+
* Pure: caller supplies lines (already tail-sliced) + prompts.
|
|
179
|
+
*/
|
|
180
|
+
function buildRebriefContext(input) {
|
|
181
|
+
const maxChars = (input.maxTokens ?? 4e3) * 4;
|
|
182
|
+
const operatorFocus = (input.originalAsk ?? "").trim();
|
|
183
|
+
const callerContext = (input.refinedAsk ?? "").trim() || (input.lastAssistantBrief ?? "").trim();
|
|
184
|
+
const doneSoFar = (input.doneSoFar ?? "").trim();
|
|
185
|
+
const askBlock = operatorFocus.length > 0 ? `Original ask (authoritative):\n${operatorFocus}` : "";
|
|
186
|
+
const callerBlock = callerContext.length > 0 ? `Current focus:\n${callerContext}` : "";
|
|
187
|
+
const doneBlock = doneSoFar.length > 0 ? `Done so far:\n${doneSoFar}` : "";
|
|
188
|
+
const reserved = askBlock.length + callerBlock.length + doneBlock.length + 256;
|
|
189
|
+
let budget = Math.max(0, Math.min(maxChars, REBRIEF_MAX_CHARS) - reserved);
|
|
190
|
+
const spans = [];
|
|
191
|
+
for (const line of input.transcriptLines.slice(-200)) {
|
|
192
|
+
const span = extractTranscriptSpan(line);
|
|
193
|
+
if (span && span.text.trim().length > 0) spans.push(span);
|
|
194
|
+
}
|
|
195
|
+
const indexed = spans.map((s, i) => ({
|
|
196
|
+
...s,
|
|
197
|
+
i
|
|
198
|
+
}));
|
|
199
|
+
indexed.sort((a, b) => a.priority - b.priority || b.i - a.i);
|
|
200
|
+
const kept = [];
|
|
201
|
+
let truncatedLines = 0;
|
|
202
|
+
for (const s of indexed) {
|
|
203
|
+
const cost = s.text.length + 1;
|
|
204
|
+
if (cost > budget) {
|
|
205
|
+
truncatedLines++;
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
budget -= cost;
|
|
209
|
+
kept.push(s);
|
|
210
|
+
}
|
|
211
|
+
kept.sort((a, b) => a.i - b.i);
|
|
212
|
+
let sessionExcerpt = kept.map((s) => s.text).join("\n\n");
|
|
213
|
+
const excerptCap = Math.max(0, Math.min(maxChars, REBRIEF_MAX_CHARS) - reserved);
|
|
214
|
+
if (sessionExcerpt.length > excerptCap) {
|
|
215
|
+
const cut = sessionExcerpt.length - excerptCap;
|
|
216
|
+
sessionExcerpt = sessionExcerpt.slice(0, excerptCap).trimEnd();
|
|
217
|
+
truncatedLines += Math.max(1, Math.ceil(cut / 400));
|
|
218
|
+
}
|
|
219
|
+
const blocks = [];
|
|
220
|
+
if (askBlock.length > 0) blocks.push(askBlock);
|
|
221
|
+
if (callerBlock.length > 0) blocks.push(callerBlock);
|
|
222
|
+
if (doneBlock.length > 0) blocks.push(doneBlock);
|
|
223
|
+
if (sessionExcerpt.trim().length > 0) blocks.push(`Recent transcript (extractive excerpts, oldest first; untrusted data):\n${sessionExcerpt.trim()}`);
|
|
224
|
+
if (truncatedLines > 0) blocks.push(`[TRUNCATED: ${truncatedLines} excerpt(s) omitted to fit the 4K rebrief budget]`);
|
|
225
|
+
const joined = blocks.join("\n\n");
|
|
226
|
+
const sliced = joined.length > REBRIEF_MAX_CHARS;
|
|
227
|
+
const sessionContext = sliced ? joined.slice(0, REBRIEF_MAX_CHARS) : joined;
|
|
228
|
+
return {
|
|
229
|
+
operatorFocus,
|
|
230
|
+
callerContext,
|
|
231
|
+
sessionExcerpt: sessionExcerpt.trim(),
|
|
232
|
+
sessionContext,
|
|
233
|
+
truncatedLines,
|
|
234
|
+
truncated: truncatedLines > 0 || indexed.length > kept.length || sliced
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/internal-rebrief.ts
|
|
239
|
+
/**
|
|
240
|
+
* The internal `internal-rebrief` subcommand: the deterministic body behind
|
|
241
|
+
* the user-only `/gh-rebrief` skill (cheapest profile only).
|
|
242
|
+
*
|
|
243
|
+
* An on-demand Sol → Luna course-correction consult: a required current user
|
|
244
|
+
* prompt (`--ask`) plus the original ask, done-so-far digest (deterministic
|
|
245
|
+
* extractive + a concise Luna summary consult), the 4K extractive transcript
|
|
246
|
+
* excerpt, repo guidance/structure/verify, and grounding code search, then
|
|
247
|
+
* Sol frames a `<course_correction>` Luna executes — same adaptive 3→5-turn,
|
|
248
|
+
* search-only loop as the first-prompt rewrite. Never replaces the user
|
|
249
|
+
* prompt; always exits 0. No per-session invocation cap by product decision:
|
|
250
|
+
* every invoke is user-triggered and self-bounded (one 30s ceiling).
|
|
251
|
+
*
|
|
252
|
+
* User-only by skill visibility (`disable-model-invocation: true` in the
|
|
253
|
+
* SKILL.md) plus a default-on binary tripwire: the command refuses unless
|
|
254
|
+
* `GH_ROUTER_REBRIEF_USER_INVOKED=1` (set by the skill wrapper; opt out with
|
|
255
|
+
* `GH_ROUTER_REBRIEF_REQUIRE_USER_INVOKED=0`). Per-invoke ceiling: at most
|
|
256
|
+
* two Sol inferences (one initial + one extension), one Luna summary, and one
|
|
257
|
+
* 30s wall-clock deadline.
|
|
258
|
+
*/
|
|
259
|
+
const SEARCH_TIMEOUT_MS = 8e3;
|
|
260
|
+
const INFER_TIMEOUT_MS = 25e3;
|
|
261
|
+
const REWRITE_TIMEOUT_MS = 3e4;
|
|
262
|
+
/** Hard-gate env: the binary refuses without the user marker — ON by default
|
|
263
|
+
* (opt OUT with `GH_ROUTER_REBRIEF_REQUIRE_USER_INVOKED=0`), so a guessed
|
|
264
|
+
* binary name alone never spends. The skill wrapper always sets the marker.
|
|
265
|
+
* Residual: the marker is an env var, so this is a tripwire, not a sandbox —
|
|
266
|
+
* see docs/gh-rebrief.md. */
|
|
267
|
+
function isRebriefHardGateEnabled(env = process.env) {
|
|
268
|
+
const v = (env.GH_ROUTER_REBRIEF_REQUIRE_USER_INVOKED ?? "").trim().toLowerCase();
|
|
269
|
+
if (v === "") return true;
|
|
270
|
+
return v !== "0" && v !== "false" && v !== "no" && v !== "off";
|
|
271
|
+
}
|
|
272
|
+
/** User-invocation marker the skill wrapper sets (soft by default). */
|
|
273
|
+
function isRebriefUserInvoked(env = process.env) {
|
|
274
|
+
const v = (env.GH_ROUTER_REBRIEF_USER_INVOKED ?? "").trim().toLowerCase();
|
|
275
|
+
return v === "1" || v === "true";
|
|
276
|
+
}
|
|
277
|
+
/** Cheapest-only gate (literal alias, lowercased). Exported for tests. */
|
|
278
|
+
function isRebriefProfileEligible(profile) {
|
|
279
|
+
return (profile ?? "").trim().toLowerCase() === "cheapest";
|
|
280
|
+
}
|
|
281
|
+
/** Parse a hook-style stdin payload. Never throws. Exported for tests. */
|
|
282
|
+
function decodeRebriefPayload(stdin) {
|
|
283
|
+
let raw = {};
|
|
284
|
+
try {
|
|
285
|
+
const p = JSON.parse(stdin);
|
|
286
|
+
if (p && typeof p === "object") raw = p;
|
|
287
|
+
} catch {}
|
|
288
|
+
return {
|
|
289
|
+
sessionId: typeof raw.session_id === "string" ? raw.session_id : "",
|
|
290
|
+
prompt: typeof raw.prompt === "string" ? raw.prompt : "",
|
|
291
|
+
transcriptPath: typeof raw.transcript_path === "string" ? raw.transcript_path : "",
|
|
292
|
+
cwd: typeof raw.cwd === "string" && raw.cwd.length > 0 ? raw.cwd : process.cwd(),
|
|
293
|
+
isSubagent: isSubagentContext(raw)
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Resolve the effective prompt: explicit `--ask` wins, then the hook prompt,
|
|
298
|
+
* then the last-prompt store. Exported for tests.
|
|
299
|
+
*/
|
|
300
|
+
function resolveRebriefPrompt(input) {
|
|
301
|
+
const ask = (input.ask ?? "").trim();
|
|
302
|
+
if (ask.length > 0) return ask;
|
|
303
|
+
const hook = (input.hookPrompt ?? "").trim();
|
|
304
|
+
if (hook.length > 0) return hook;
|
|
305
|
+
return (input.storedPrompt ?? "").trim();
|
|
306
|
+
}
|
|
307
|
+
/** Read the last N non-empty lines of a file, byte-capped (F6).
|
|
308
|
+
* Never loads more than `maxBytes` (default 1 MiB) — transcripts can be
|
|
309
|
+
* tens of MB and this runs inside a 30s budget. Never throws. */
|
|
310
|
+
function readTranscriptTail(transcriptPath, maxLines, maxBytes = 1048576) {
|
|
311
|
+
try {
|
|
312
|
+
if (!transcriptPath || !existsSync(transcriptPath)) return [];
|
|
313
|
+
const size = statSync(transcriptPath).size;
|
|
314
|
+
if (size <= 0) return [];
|
|
315
|
+
let raw;
|
|
316
|
+
if (size <= maxBytes) raw = readFileSync(transcriptPath, "utf8");
|
|
317
|
+
else {
|
|
318
|
+
const fd = openSync(transcriptPath, "r");
|
|
319
|
+
try {
|
|
320
|
+
const buf = Buffer.alloc(maxBytes);
|
|
321
|
+
const read = readSync(fd, buf, 0, maxBytes, size - maxBytes);
|
|
322
|
+
raw = buf.subarray(0, read).toString("utf8");
|
|
323
|
+
} finally {
|
|
324
|
+
try {
|
|
325
|
+
closeSync(fd);
|
|
326
|
+
} catch {}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
if (raw.length === 0) return [];
|
|
330
|
+
return raw.split("\n").slice(-Math.max(1, maxLines) * 2).filter((l) => l.trim().length > 0).slice(-Math.max(1, maxLines));
|
|
331
|
+
} catch {
|
|
332
|
+
return [];
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function readStdin() {
|
|
336
|
+
try {
|
|
337
|
+
if (process.stdin.isTTY) return "";
|
|
338
|
+
return readFileSync(0, "utf8");
|
|
339
|
+
} catch {
|
|
340
|
+
return "";
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const internalRebrief = defineCommand({
|
|
344
|
+
meta: {
|
|
345
|
+
name: "internal-rebrief",
|
|
346
|
+
description: "Internal: on-demand cheapest rebrief. Re-runs the Sol grounded execution brief with 4K compressed recent context. Cheapest profile only, user-invoked. Always exits 0."
|
|
347
|
+
},
|
|
348
|
+
args: { ask: {
|
|
349
|
+
type: "string",
|
|
350
|
+
description: "Optional refined ask ($ARGUMENTS from /gh-rebrief). Wins over the stored prompt.",
|
|
351
|
+
required: false
|
|
352
|
+
} },
|
|
353
|
+
async run({ args }) {
|
|
354
|
+
try {
|
|
355
|
+
const payload = decodeRebriefPayload(readStdin());
|
|
356
|
+
let transcriptPath = payload.transcriptPath;
|
|
357
|
+
const workspace = payload.cwd;
|
|
358
|
+
let bindingSessionId = "";
|
|
359
|
+
if (payload.sessionId.length === 0 || payload.transcriptPath.length === 0) {
|
|
360
|
+
const binding = await fileRebriefBindingStore(stopReviewStateDir()).read(workspace).catch(() => null);
|
|
361
|
+
if (binding) {
|
|
362
|
+
if (payload.sessionId.length === 0) bindingSessionId = binding.sessionId;
|
|
363
|
+
if (payload.transcriptPath.length === 0) transcriptPath = binding.transcriptPath;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
const effectiveSessionId = payload.sessionId.length > 0 ? payload.sessionId : bindingSessionId;
|
|
367
|
+
const profile = (process.env.GH_ROUTER_PROFILE ?? "").trim().toLowerCase();
|
|
368
|
+
const runtime = hookMcpRuntimeFromEnv();
|
|
369
|
+
const searchEnabled = process.env.GH_ROUTER_SEARCH_ENABLED !== void 0 ? process.env.GH_ROUTER_SEARCH_ENABLED === "1" : process.env.GH_ROUTER_ENABLE_SEMANTIC_SEARCH === "1";
|
|
370
|
+
const bluebirdEnabled = process.env.GH_ROUTER_BLUEBIRD_ENABLED === "1";
|
|
371
|
+
const searchTip = getPromptSearchTip(searchEnabled, bluebirdEnabled);
|
|
372
|
+
const emit = async (text) => {
|
|
373
|
+
if (text.trim().length === 0) return;
|
|
374
|
+
await new Promise((resolve) => process.stdout.write(`${text}\n`, () => resolve()));
|
|
375
|
+
};
|
|
376
|
+
if (isRebriefHardGateEnabled() && !isRebriefUserInvoked()) {
|
|
377
|
+
await emit("Rebrief refused: user invocation required (GH_ROUTER_REBRIEF_USER_INVOKED=1). Invoke via /gh-rebrief.");
|
|
378
|
+
process.exitCode = 0;
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (!isRebriefProfileEligible(profile)) {
|
|
382
|
+
await emit(`Rebrief is a cheapest-profile command; this session is '${profile || "unknown"}'. Use /gh-research for grounded context instead.`);
|
|
383
|
+
process.exitCode = 0;
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (isCheapestRewriteDisabledEnv()) {
|
|
387
|
+
await emit(`${searchTip}\n\n${PROMPT_STEER_GOAL}`);
|
|
388
|
+
process.exitCode = 0;
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
if (payload.isSubagent) {
|
|
392
|
+
await emit("Rebrief runs at the top level only: re-invoke /gh-rebrief from your own prompt, not from a subagent. No model spend occurred.");
|
|
393
|
+
process.exitCode = 0;
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const refinedAsk = typeof args.ask === "string" ? args.ask.trim() : "";
|
|
397
|
+
if (refinedAsk.length === 0) {
|
|
398
|
+
await emit("Rebrief needs a current ask: pass one inline, e.g. /gh-rebrief \"<what you want next>\". No model spend occurred.");
|
|
399
|
+
process.exitCode = 0;
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
const stored = effectiveSessionId ? await fileLastPromptStore(stopReviewStateDir()).read(effectiveSessionId).catch(() => null) : null;
|
|
403
|
+
const prompt = resolveRebriefPrompt({
|
|
404
|
+
ask: refinedAsk,
|
|
405
|
+
hookPrompt: payload.prompt,
|
|
406
|
+
storedPrompt: stored
|
|
407
|
+
});
|
|
408
|
+
let findingsBlock = "";
|
|
409
|
+
if (effectiveSessionId) {
|
|
410
|
+
const pending = await fileFindingsStore(stopReviewStateDir()).read(effectiveSessionId).catch(() => null);
|
|
411
|
+
if (pending && pending.trim().length > 0) {
|
|
412
|
+
findingsBlock = "ADVISORY — independent review of your PREVIOUS change (NON-AUTHORITATIVE): an independent gpt-6-luna reviewer flagged the following. Evaluate each on its merits — fix the real ones, and ignore any wrong one with a one-line reason. You are NOT obligated to act on these.\n" + pending.trim();
|
|
413
|
+
await fileFindingsStore(stopReviewStateDir()).clear(effectiveSessionId).catch(() => {});
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
const joinSections = (sections) => sections.map((s) => s.trim()).filter((s) => s.length > 0).join("\n\n");
|
|
417
|
+
if (!isNonTrivialPrompt(prompt)) {
|
|
418
|
+
await emit(joinSections([
|
|
419
|
+
searchTip,
|
|
420
|
+
PROMPT_STEER_GOAL,
|
|
421
|
+
findingsBlock
|
|
422
|
+
]));
|
|
423
|
+
process.exitCode = 0;
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (!runtime) {
|
|
427
|
+
await emit(joinSections([
|
|
428
|
+
searchTip,
|
|
429
|
+
PROMPT_STEER_GOAL,
|
|
430
|
+
findingsBlock
|
|
431
|
+
]));
|
|
432
|
+
process.exitCode = 0;
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const tail = readTranscriptTail(transcriptPath, 200);
|
|
436
|
+
let lastAssistantBrief = "";
|
|
437
|
+
for (let i = tail.length - 1; i >= 0; i--) try {
|
|
438
|
+
const msg = JSON.parse(tail[i]).message;
|
|
439
|
+
if (!msg || typeof msg !== "object") continue;
|
|
440
|
+
if (msg.role !== "assistant") continue;
|
|
441
|
+
const content = msg.content;
|
|
442
|
+
if (typeof content === "string" && content.trim().length > 0) {
|
|
443
|
+
lastAssistantBrief = content.trim().slice(0, 2e3);
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
if (Array.isArray(content)) {
|
|
447
|
+
for (const part of content) if (part && typeof part === "object" && part.type === "text" && typeof part.text === "string" && part.text.trim().length > 0) {
|
|
448
|
+
lastAssistantBrief = part.text.trim().slice(0, 2e3);
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
if (lastAssistantBrief) break;
|
|
452
|
+
}
|
|
453
|
+
} catch {}
|
|
454
|
+
const digest = buildDoneDigest(tail);
|
|
455
|
+
let lunaSummary = "";
|
|
456
|
+
try {
|
|
457
|
+
const summaryTranscript = tail.slice(-120).join("\n").slice(-12e3);
|
|
458
|
+
lunaSummary = (await callInference({
|
|
459
|
+
serverUrl: runtime.serverUrl,
|
|
460
|
+
model: "gpt-6-luna",
|
|
461
|
+
instructions: "You are summarizing a coding session for a course correction. Answer in <=2K characters: what is done and verifiable, what is blocked/open, and what the last ask was. Extractive only — never invent facts; prefer file:line references seen in the transcript.",
|
|
462
|
+
input: `USER ASK:\n${prompt}\n\nTRANSCRIPT:\n${summaryTranscript}`,
|
|
463
|
+
effort: "high",
|
|
464
|
+
timeoutMs: INFER_TIMEOUT_MS
|
|
465
|
+
})).trim().slice(0, 2048);
|
|
466
|
+
} catch {
|
|
467
|
+
lunaSummary = "";
|
|
468
|
+
}
|
|
469
|
+
const doneSoFar = [digest.trim().length > 0 ? `DETERMINISTIC DIGEST:\n${digest.trim()}` : "", lunaSummary.trim().length > 0 ? `LUNA STATE SUMMARY (<=2K, advisory):\n${lunaSummary.trim()}` : ""].filter((s) => s.length > 0).join("\n\n");
|
|
470
|
+
const rebrief = buildRebriefContext({
|
|
471
|
+
transcriptLines: tail,
|
|
472
|
+
originalAsk: stored ?? payload.prompt,
|
|
473
|
+
refinedAsk,
|
|
474
|
+
lastAssistantBrief,
|
|
475
|
+
doneSoFar
|
|
476
|
+
});
|
|
477
|
+
const statik = await (async () => {
|
|
478
|
+
try {
|
|
479
|
+
return buildStaticPack(workspace);
|
|
480
|
+
} catch {
|
|
481
|
+
return {
|
|
482
|
+
agentsMd: "",
|
|
483
|
+
claudeMd: "",
|
|
484
|
+
repoStructure: "",
|
|
485
|
+
verifyCommand: ""
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
})();
|
|
489
|
+
const result = await runCheapestRewrite({
|
|
490
|
+
prompt,
|
|
491
|
+
searchEnabled,
|
|
492
|
+
bluebirdEnabled,
|
|
493
|
+
sessionContext: rebrief.sessionContext,
|
|
494
|
+
io: {
|
|
495
|
+
searchCode: async (query, mode, signal) => {
|
|
496
|
+
const r = await callMcpTool({
|
|
497
|
+
runtime,
|
|
498
|
+
group: "search",
|
|
499
|
+
tool: "code",
|
|
500
|
+
args: {
|
|
501
|
+
query,
|
|
502
|
+
workspace,
|
|
503
|
+
mode,
|
|
504
|
+
limit: 10,
|
|
505
|
+
summary: false
|
|
506
|
+
},
|
|
507
|
+
timeoutMs: SEARCH_TIMEOUT_MS,
|
|
508
|
+
signal
|
|
509
|
+
});
|
|
510
|
+
return r.isError ? "" : r.text;
|
|
511
|
+
},
|
|
512
|
+
inferSol: (system, user, signal) => callInference({
|
|
513
|
+
serverUrl: runtime.serverUrl,
|
|
514
|
+
model: CHEAPEST_REWRITE_MODEL,
|
|
515
|
+
instructions: system,
|
|
516
|
+
input: user,
|
|
517
|
+
effort: CHEAPEST_REWRITE_EFFORT,
|
|
518
|
+
timeoutMs: INFER_TIMEOUT_MS,
|
|
519
|
+
signal
|
|
520
|
+
}),
|
|
521
|
+
staticPack: async () => statik,
|
|
522
|
+
hasRewriteRun: async () => false,
|
|
523
|
+
markRewriteRun: async () => {},
|
|
524
|
+
timeoutMs: REWRITE_TIMEOUT_MS,
|
|
525
|
+
buildSystemPrompt: buildRebriefSystem
|
|
526
|
+
}
|
|
527
|
+
}).catch(() => ({
|
|
528
|
+
brief: null,
|
|
529
|
+
timedOut: false
|
|
530
|
+
}));
|
|
531
|
+
if (result.brief && result.brief.length > 0) await emit(joinSections([
|
|
532
|
+
searchTip,
|
|
533
|
+
result.brief,
|
|
534
|
+
findingsBlock
|
|
535
|
+
]));
|
|
536
|
+
else await emit(joinSections([
|
|
537
|
+
searchTip,
|
|
538
|
+
parseBoolEnv(process.env.GH_ROUTER_DISABLE_PROMPT_STEER) !== true ? PROMPT_STEER_GOAL : "",
|
|
539
|
+
findingsBlock
|
|
540
|
+
]));
|
|
541
|
+
} catch {}
|
|
542
|
+
process.exitCode = 0;
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
//#endregion
|
|
546
|
+
export { internalRebrief };
|
|
547
|
+
|
|
548
|
+
//# sourceMappingURL=internal-rebrief-BH9PMJhF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-rebrief-BH9PMJhF.js","names":[],"sources":["../src/lib/cheapest-rebrief-context.ts","../src/internal-rebrief.ts"],"sourcesContent":["/**\n * On-demand cheapest rebrief context (`/gh-rebrief`): extractive, 4K-capped\n * recent-session excerpt for the Sol rewriter.\n *\n * Design (research-grounded, see docs/gh-rebrief.md):\n * - EXTRACTIVE ONLY: select verbatim spans, never rephrase or summarize.\n * Rephrasing breaks identifiers/paths/numbers and compounds drift across\n * compactions (CliffCompaction: truncate/drop, never rewrite; Paritok-4B:\n * 96% identifier fidelity via extraction).\n * - Never compact-a-compaction: each rebrief reads the live transcript tail,\n * never a prior brief.\n * - Priority order until the budget fills: operator focus (original ask,\n * pinned verbatim) > caller context (refined ask / last assistant brief)\n * > error tool results > Task/Agent/WebFetch summaries > last turns raw >\n * file:line cites.\n * - Pure + dependency-free so tests run with zero IO; the command layer\n * (`internal-rebrief`) owns file reads.\n */\n\n/** Token budget for the rebrief session excerpt (tokens, o200k heuristic). */\nexport const REBRIEF_MAX_TOKENS = 4_000 as const\n/** Char fallback when no tokenizer is available (~4 chars/token). */\nexport const REBRIEF_MAX_CHARS = 16_000 as const\n/** Max transcript JSONL lines scanned from the tail (bounded scan). */\nexport const REBRIEF_MAX_TAIL_LINES = 200 as const\n/** Per-excerpt line cap so one pathological turn cannot eat the budget. */\nexport const REBRIEF_PER_EXCERPT_LINES = 40 as const\n\nexport interface RebriefContextResult {\n /** Original ask, verbatim (pinned, never truncated by selection). */\n operatorFocus: string\n /** Refined ask (`$ARGUMENTS`) or last assistant brief, verbatim. */\n callerContext: string\n /** Prioritized, extractive session excerpt, capped. */\n sessionExcerpt: string\n /** Full `SESSION CONTEXT` block ready for `sessionContext` (capped). */\n sessionContext: string\n /** Number of transcript lines dropped by the budget. */\n truncatedLines: number\n /** True when any truncation occurred. */\n truncated: boolean\n}\n\ninterface TranscriptLine {\n /** Verbatim text span extracted from one JSONL line (\"\" = skip). */\n text: string\n /** Priority class: lower wins (0 = highest). */\n priority: number\n}\n\n/**\n * Extract one verbatim span from a Claude Code JSONL transcript line.\n * Returns null when the line carries no usable text. Never throws.\n */\nexport function extractTranscriptSpan(line: string): TranscriptLine | null {\n const trimmed = line.trim()\n if (trimmed.length === 0) return null\n let obj: unknown\n try {\n obj = JSON.parse(trimmed)\n } catch {\n // Non-JSON launch/log noise: keep short lines verbatim (they are often\n // error banners), drop long blobs.\n return trimmed.length <= 280\n ? { text: trimmed.slice(0, 280), priority: 4 }\n : null\n }\n if (!obj || typeof obj !== \"object\" || Array.isArray(obj)) return null\n const rec = obj as Record<string, unknown>\n // Skip subagent transcript lines (not this session's trajectory).\n if (rec.parent_tool_use_id !== undefined && rec.parent_tool_use_id !== null) {\n return null\n }\n const type = rec.type\n // `result` events: keep errors + summaries only (usage heartbeats are noise).\n if (type === \"result\") {\n const err = rec.is_error === true\n || (typeof rec.status === \"string\" && rec.status.toLowerCase().includes(\"error\"))\n const text = typeof rec.result === \"string\"\n ? rec.result\n : typeof rec.summary === \"string\"\n ? rec.summary\n : \"\"\n if (text.trim().length === 0) return null\n return {\n text: headLines(text.trim(), REBRIEF_PER_EXCERPT_LINES),\n priority: err ? 1 : 4,\n }\n }\n const msg = (rec as { message?: unknown }).message\n if (!msg || typeof msg !== \"object\" || Array.isArray(msg)) return null\n const m = msg as Record<string, unknown>\n const role = typeof m.role === \"string\" ? m.role : \"unknown\"\n const content = m.content\n if (typeof content === \"string\") {\n return content.trim().length > 0\n ? { text: headLines(content.trim(), REBRIEF_PER_EXCERPT_LINES), priority: role === \"user\" ? 3 : 3 }\n : null\n }\n if (!Array.isArray(content)) return null\n const spans: Array<{ text: string; priority: number }> = []\n for (const part of content) {\n if (!part || typeof part !== \"object\") continue\n const b = part as Record<string, unknown>\n if (b.type === \"text\" && typeof b.text === \"string\" && b.text.trim().length > 0) {\n spans.push({ text: b.text.trim(), priority: 3 })\n } else if (b.type === \"tool_use\") {\n const name = typeof b.name === \"string\" ? b.name : \"?\"\n // Bulk-input tools collapse to a path/size marker (advisor rule).\n if (name === \"Write\" || name === \"Edit\") {\n const serialized = JSON.stringify(b.input ?? {})\n // Keep the path — it is the load-bearing token (F7); elide the body.\n const inputObj = (b.input ?? {}) as Record<string, unknown>\n const filePath = typeof inputObj.file_path === \"string\"\n ? inputObj.file_path\n : typeof inputObj.file === \"string\"\n ? inputObj.file\n : typeof inputObj.path === \"string\"\n ? inputObj.path\n : \"\"\n const where = filePath ? ` ${filePath}` : \"\"\n spans.push({ text: `[tool_use ${name}${where}: ~${serialized.length} chars elided (bulk input)]`, priority: 5 })\n } else {\n const summary = summaryTools.has(name)\n const input = JSON.stringify(b.input ?? {}).slice(0, summary ? 2_000 : 500)\n spans.push({ text: `[tool_use ${name}: ${input}]`, priority: summary ? 2 : 4 })\n }\n } else if (b.type === \"tool_result\") {\n const raw = typeof b.content === \"string\" ? b.content : JSON.stringify(b.content ?? \"\")\n const err = b.is_error === true\n // Errors are prime rebrief signal; everything else is ordered by\n // recency. Deliberately no prose-vs-dump heuristic here: a char-run\n // test cannot tell pretty-printed JSON from prose, and summaries from\n // Task/Agent/WebFetch already win priority via their tool_use entries.\n spans.push({\n text: `[tool_result${err ? \" error=true\" : \"\"}]:\\n${headTail(raw.trim(), err ? 6_000 : 3_000)}`,\n priority: err ? 1 : 4,\n })\n }\n }\n if (spans.length === 0) return null\n spans.sort((a, b) => a.priority - b.priority)\n const best = spans[0]\n // Join same-priority spans so one line keeps its richest signal class.\n const same = spans.filter((s) => s.priority === best.priority).map((s) => s.text)\n return { text: headLines(same.join(\"\\n\"), REBRIEF_PER_EXCERPT_LINES), priority: best.priority }\n}\n\nconst summaryTools = new Set([\"Task\", \"Agent\", \"WebFetch\"])\n\nfunction headLines(text: string, maxLines: number): string {\n const lines = text.split(\"\\n\")\n if (lines.length <= maxLines) return text\n return `${lines.slice(0, maxLines).join(\"\\n\")}\\n…[${lines.length - maxLines} lines elided]…`\n}\n\nfunction headTail(text: string, maxChars: number): string {\n if (maxChars <= 0) return \"\"\n if (text.length <= maxChars) return text\n const head = Math.floor(maxChars / 2)\n const tail = maxChars - head\n return `${text.slice(0, head)}\\n…[elided]…\\n${text.slice(text.length - tail)}`\n}\n\n/** Rough token estimate (o200k ~4 chars/token) for budget selection. */\nexport function estimateTokens(text: string): number {\n return Math.ceil(text.length / 4)\n}\n\n/** Cap for the deterministic done-so-far digest (chars). */\nexport const REBRIEF_DIGEST_MAX_CHARS = 2_000 as const\n\n/**\n * Deterministic \"what has been done\" digest from a transcript tail:\n * extractive only, capped, never invents facts. Assistant text spans,\n * tool names used, files mutated (Write/Edit path markers), and error\n * results — the floor layer of the dual done-so-far. The Luna summary\n * consult (Layer 2, produced by the command layer) sits on top of this.\n */\nexport function buildDoneDigest(\n transcriptLines: ReadonlyArray<string>,\n maxChars: number = REBRIEF_DIGEST_MAX_CHARS,\n): string {\n const parts: Array<string> = []\n const paths = new Set<string>()\n const tools = new Set<string>()\n const texts: Array<string> = []\n const errors: Array<string> = []\n for (const line of transcriptLines) {\n const trimmed = line.trim()\n if (trimmed.length === 0) continue\n let obj: unknown\n try {\n obj = JSON.parse(trimmed)\n } catch {\n continue\n }\n if (!obj || typeof obj !== \"object\" || Array.isArray(obj)) continue\n const rec = obj as Record<string, unknown>\n if (rec.parent_tool_use_id !== undefined && rec.parent_tool_use_id !== null) continue\n if (rec.type === \"result\") {\n if (rec.is_error === true || (typeof rec.status === \"string\" && rec.status.toLowerCase().includes(\"error\"))) {\n errors.push(headTail(typeof rec.result === \"string\" ? rec.result : typeof rec.summary === \"string\" ? rec.summary : \"\", 400))\n }\n continue\n }\n const msg = (rec as { message?: unknown }).message\n if (!msg || typeof msg !== \"object\" || Array.isArray(msg)) continue\n const m = msg as Record<string, unknown>\n const role = typeof m.role === \"string\" ? m.role : \"unknown\"\n const content = m.content\n // Only the assistant's own statements belong in a \"what has been done\"\n // digest; user text would duplicate the current ask and could smuggle a\n // prompt-injection attempt into the done-so-far block Sol treats as\n // authoritative grounding.\n if (role !== \"assistant\") continue\n if (typeof content === \"string\") {\n if (content.trim().length > 0) texts.push(headLines(content.trim(), 8))\n continue\n }\n if (!Array.isArray(content)) continue\n for (const part of content) {\n if (!part || typeof part !== \"object\") continue\n const b = part as Record<string, unknown>\n if (b.type === \"text\" && typeof b.text === \"string\" && b.text.trim().length > 0) {\n texts.push(headLines(b.text.trim(), 8))\n } else if (b.type === \"tool_use\") {\n const name = typeof b.name === \"string\" ? b.name : \"?\"\n tools.add(name)\n if (name === \"Write\" || name === \"Edit\") {\n const inputObj = (b.input ?? {}) as Record<string, unknown>\n const filePath = typeof inputObj.file_path === \"string\"\n ? inputObj.file_path\n : typeof inputObj.file === \"string\"\n ? inputObj.file\n : typeof inputObj.path === \"string\"\n ? inputObj.path\n : \"\"\n if (filePath) paths.add(filePath)\n }\n } else if (b.type === \"tool_result\" && b.is_error === true) {\n const raw = typeof b.content === \"string\" ? b.content : JSON.stringify(b.content ?? \"\")\n errors.push(headTail(raw.trim(), 400))\n }\n }\n }\n if (tools.size > 0) parts.push(`Tools used: ${[...tools].sort().join(\", \")}`)\n if (paths.size > 0) parts.push(`Files mutated: ${[...paths].sort().join(\", \")}`)\n if (errors.length > 0) parts.push(`Errors:\\n${errors.join(\"\\n---\\n\")}`)\n if (texts.length > 0) parts.push(`Assistant text (recent):\\n${texts.slice(-6).join(\"\\n---\\n\")}`)\n const joined = parts.join(\"\\n\\n\")\n return joined.length <= maxChars ? joined : `${joined.slice(0, maxChars).trimEnd()}\\n…[digest truncated]…`\n}\n\n/**\n * Build the capped 4K rebrief context from a transcript tail.\n * Pure: caller supplies lines (already tail-sliced) + prompts.\n */\nexport function buildRebriefContext(input: {\n transcriptLines: ReadonlyArray<string>\n originalAsk?: string\n refinedAsk?: string\n lastAssistantBrief?: string\n /** Dual-layer done-so-far block (deterministic digest + Luna summary). */\n doneSoFar?: string\n maxTokens?: number\n}): RebriefContextResult {\n const maxTokens = input.maxTokens ?? REBRIEF_MAX_TOKENS\n const maxChars = maxTokens * 4\n const operatorFocus = (input.originalAsk ?? \"\").trim()\n const callerContext = (input.refinedAsk ?? \"\").trim()\n || (input.lastAssistantBrief ?? \"\").trim()\n const doneSoFar = (input.doneSoFar ?? \"\").trim()\n // The pinned blocks are inviolable: the excerpt gets whatever budget is\n // left AFTER them (plus fixed labels), never the reverse. A huge ask\n // shrinks the excerpt to zero rather than being sliced itself (B6.1).\n const askBlock = operatorFocus.length > 0 ? `Original ask (authoritative):\\n${operatorFocus}` : \"\"\n const callerBlock = callerContext.length > 0 ? `Current focus:\\n${callerContext}` : \"\"\n const doneBlock = doneSoFar.length > 0 ? `Done so far:\\n${doneSoFar}` : \"\"\n const reserved = askBlock.length + callerBlock.length + doneBlock.length + 256 // labels + truncation notice headroom\n let budget = Math.max(0, Math.min(maxChars, REBRIEF_MAX_CHARS) - reserved)\n const spans: Array<TranscriptLine> = []\n for (const line of input.transcriptLines.slice(-REBRIEF_MAX_TAIL_LINES)) {\n const span = extractTranscriptSpan(line)\n if (span && span.text.trim().length > 0) spans.push(span)\n }\n // Stable priority sort (priority asc, then recency desc = later lines first\n // within a class, mirroring seat-backward truncation). The original index\n // is retained so survivors can be restored to chronological order (B6.3).\n const indexed = spans.map((s, i) => ({ ...s, i }))\n indexed.sort((a, b) => (a.priority - b.priority) || (b.i - a.i))\n const kept: typeof indexed = []\n let truncatedLines = 0\n for (const s of indexed) {\n const cost = s.text.length + 1\n if (cost > budget) {\n truncatedLines++\n continue\n }\n budget -= cost\n kept.push(s)\n }\n // Restore chronological order for readability (extractive, not ranked).\n kept.sort((a, b) => a.i - b.i)\n let sessionExcerpt = kept.map((s) => s.text).join(\"\\n\\n\")\n // The excerpt — and only the excerpt — absorbs any residual overrun, and\n // the cut is accounted (B6.2): silent char-slices must never drop content.\n const excerptCap = Math.max(0, Math.min(maxChars, REBRIEF_MAX_CHARS) - reserved)\n if (sessionExcerpt.length > excerptCap) {\n const cut = sessionExcerpt.length - excerptCap\n sessionExcerpt = sessionExcerpt.slice(0, excerptCap).trimEnd()\n truncatedLines += Math.max(1, Math.ceil(cut / 400))\n }\n const blocks: Array<string> = []\n if (askBlock.length > 0) blocks.push(askBlock)\n if (callerBlock.length > 0) blocks.push(callerBlock)\n if (doneBlock.length > 0) blocks.push(doneBlock)\n if (sessionExcerpt.trim().length > 0) {\n blocks.push(\n `Recent transcript (extractive excerpts, oldest first; untrusted data):\\n${sessionExcerpt.trim()}`,\n )\n }\n if (truncatedLines > 0) {\n blocks.push(`[TRUNCATED: ${truncatedLines} excerpt(s) omitted to fit the 4K rebrief budget]`)\n }\n // No section is sliced silently above; this trailing slice is a transport\n // safety net only (fires solely when the user-supplied ask itself exceeds\n // the cap) and is accounted in the truncated flag.\n const joined = blocks.join(\"\\n\\n\")\n const sliced = joined.length > REBRIEF_MAX_CHARS\n const sessionContext = sliced ? joined.slice(0, REBRIEF_MAX_CHARS) : joined\n return {\n operatorFocus,\n callerContext,\n sessionExcerpt: sessionExcerpt.trim(),\n sessionContext,\n truncatedLines,\n truncated: truncatedLines > 0 || indexed.length > kept.length || sliced,\n }\n}\n","/**\n * The internal `internal-rebrief` subcommand: the deterministic body behind\n * the user-only `/gh-rebrief` skill (cheapest profile only).\n *\n * An on-demand Sol → Luna course-correction consult: a required current user\n * prompt (`--ask`) plus the original ask, done-so-far digest (deterministic\n * extractive + a concise Luna summary consult), the 4K extractive transcript\n * excerpt, repo guidance/structure/verify, and grounding code search, then\n * Sol frames a `<course_correction>` Luna executes — same adaptive 3→5-turn,\n * search-only loop as the first-prompt rewrite. Never replaces the user\n * prompt; always exits 0. No per-session invocation cap by product decision:\n * every invoke is user-triggered and self-bounded (one 30s ceiling).\n *\n * User-only by skill visibility (`disable-model-invocation: true` in the\n * SKILL.md) plus a default-on binary tripwire: the command refuses unless\n * `GH_ROUTER_REBRIEF_USER_INVOKED=1` (set by the skill wrapper; opt out with\n * `GH_ROUTER_REBRIEF_REQUIRE_USER_INVOKED=0`). Per-invoke ceiling: at most\n * two Sol inferences (one initial + one extension), one Luna summary, and one\n * 30s wall-clock deadline.\n */\n\nimport { defineCommand } from \"citty\"\n\nimport { closeSync, existsSync, openSync, readFileSync, readSync, statSync } from \"node:fs\"\n\nimport { buildStaticPack } from \"./internal-prompt-submit\"\nimport {\n buildDoneDigest,\n buildRebriefContext,\n REBRIEF_MAX_TAIL_LINES,\n} from \"./lib/cheapest-rebrief-context\"\nimport {\n buildRebriefSystem,\n CHEAPEST_REWRITE_EFFORT,\n CHEAPEST_REWRITE_MODEL,\n isCheapestRewriteDisabledEnv,\n} from \"./lib/cheapest-prompt-rewrite\"\nimport { parseBoolEnv } from \"./lib/exec\"\nimport { callInference, callMcpTool, hookMcpRuntimeFromEnv } from \"./lib/orchestration/hook-mcp-client\"\nimport {\n getPromptSearchTip,\n isNonTrivialPrompt,\n PROMPT_STEER_GOAL,\n} from \"./lib/orchestration/prompt-submit-hook\"\nimport {\n fileFindingsStore,\n fileLastPromptStore,\n fileRebriefBindingStore,\n isSubagentContext,\n stopReviewStateDir,\n} from \"./lib/orchestration/stop-gate-policy\"\nimport { runCheapestRewrite } from \"./lib/cheapest-prompt-rewrite\"\n\nconst SEARCH_TIMEOUT_MS = 8_000\nconst INFER_TIMEOUT_MS = 25_000\nconst REWRITE_TIMEOUT_MS = 30_000\n\n/** Hard-gate env: the binary refuses without the user marker — ON by default\n * (opt OUT with `GH_ROUTER_REBRIEF_REQUIRE_USER_INVOKED=0`), so a guessed\n * binary name alone never spends. The skill wrapper always sets the marker.\n * Residual: the marker is an env var, so this is a tripwire, not a sandbox —\n * see docs/gh-rebrief.md. */\nexport function isRebriefHardGateEnabled(env: NodeJS.ProcessEnv = process.env): boolean {\n const v = (env.GH_ROUTER_REBRIEF_REQUIRE_USER_INVOKED ?? \"\").trim().toLowerCase()\n if (v === \"\") return true\n return v !== \"0\" && v !== \"false\" && v !== \"no\" && v !== \"off\"\n}\n\n/** User-invocation marker the skill wrapper sets (soft by default). */\nexport function isRebriefUserInvoked(env: NodeJS.ProcessEnv = process.env): boolean {\n const v = (env.GH_ROUTER_REBRIEF_USER_INVOKED ?? \"\").trim().toLowerCase()\n return v === \"1\" || v === \"true\"\n}\n\n/** Cheapest-only gate (literal alias, lowercased). Exported for tests. */\nexport function isRebriefProfileEligible(profile: string | undefined): boolean {\n return (profile ?? \"\").trim().toLowerCase() === \"cheapest\"\n}\n\nexport interface RebriefPayload {\n sessionId: string\n prompt: string\n transcriptPath: string\n cwd: string\n isSubagent: boolean\n}\n\n/** Parse a hook-style stdin payload. Never throws. Exported for tests. */\nexport function decodeRebriefPayload(stdin: string): RebriefPayload {\n let raw: Record<string, unknown> = {}\n try {\n const p: unknown = JSON.parse(stdin)\n if (p && typeof p === \"object\") raw = p as Record<string, unknown>\n } catch {\n /* fall through with empty payload */\n }\n return {\n sessionId: typeof raw.session_id === \"string\" ? raw.session_id : \"\",\n prompt: typeof raw.prompt === \"string\" ? raw.prompt : \"\",\n transcriptPath: typeof raw.transcript_path === \"string\" ? raw.transcript_path : \"\",\n cwd: typeof raw.cwd === \"string\" && raw.cwd.length > 0 ? raw.cwd : process.cwd(),\n isSubagent: isSubagentContext(raw),\n }\n}\n\n/**\n * Resolve the effective prompt: explicit `--ask` wins, then the hook prompt,\n * then the last-prompt store. Exported for tests.\n */\nexport function resolveRebriefPrompt(input: {\n ask?: string\n hookPrompt?: string\n storedPrompt?: string | null\n}): string {\n const ask = (input.ask ?? \"\").trim()\n if (ask.length > 0) return ask\n const hook = (input.hookPrompt ?? \"\").trim()\n if (hook.length > 0) return hook\n return (input.storedPrompt ?? \"\").trim()\n}\n\n/** Read the last N non-empty lines of a file, byte-capped (F6).\n * Never loads more than `maxBytes` (default 1 MiB) — transcripts can be\n * tens of MB and this runs inside a 30s budget. Never throws. */\nexport function readTranscriptTail(\n transcriptPath: string,\n maxLines: number,\n maxBytes = 1_048_576,\n): Array<string> {\n try {\n if (!transcriptPath || !existsSync(transcriptPath)) return []\n const size = statSync(transcriptPath).size\n if (size <= 0) return []\n let raw: string\n if (size <= maxBytes) {\n raw = readFileSync(transcriptPath, \"utf8\")\n } else {\n const fd = openSync(transcriptPath, \"r\")\n try {\n const buf = Buffer.alloc(maxBytes)\n const read = readSync(fd, buf, 0, maxBytes, size - maxBytes)\n raw = buf.subarray(0, read).toString(\"utf8\")\n } finally {\n try {\n closeSync(fd)\n } catch {\n /* best-effort close; the process is short-lived either way */\n }\n }\n }\n if (raw.length === 0) return []\n return raw.split(\"\\n\").slice(-Math.max(1, maxLines) * 2).filter((l) => l.trim().length > 0).slice(-Math.max(1, maxLines))\n } catch {\n return []\n }\n}\n\nfunction readStdin(): string {\n try {\n if (process.stdin.isTTY) return \"\"\n return readFileSync(0, \"utf8\")\n } catch {\n return \"\"\n }\n}\n\nexport const internalRebrief = defineCommand({\n meta: {\n name: \"internal-rebrief\",\n description:\n \"Internal: on-demand cheapest rebrief. Re-runs the Sol grounded execution brief \"\n + \"with 4K compressed recent context. Cheapest profile only, user-invoked. Always exits 0.\",\n },\n args: {\n ask: {\n type: \"string\",\n description: \"Optional refined ask ($ARGUMENTS from /gh-rebrief). Wins over the stored prompt.\",\n required: false,\n },\n },\n async run({ args }) {\n try {\n const stdin = readStdin()\n const payload = decodeRebriefPayload(stdin)\n // No path/session overrides (B4/B5) — the CLI pass-through is --ask only.\n let transcriptPath = payload.transcriptPath\n const workspace = payload.cwd\n // When invoked by the SKILL's Bash step there is NO hook stdin, so the\n // payload is empty. Fall back to the per-workspace binding the\n // UserPromptSubmit hook refreshes on every prompt — this is the only\n // intended way the rebrief command can find the live transcript +\n // session id without being passed one explicitly. If binding is stale\n // or absent, transcript context is empty by design (the consult still\n // runs on static pack + search facts).\n let bindingSessionId = \"\"\n if (payload.sessionId.length === 0 || payload.transcriptPath.length === 0) {\n const binding = await fileRebriefBindingStore(stopReviewStateDir())\n .read(workspace)\n .catch(() => null)\n if (binding) {\n if (payload.sessionId.length === 0) bindingSessionId = binding.sessionId\n if (payload.transcriptPath.length === 0) transcriptPath = binding.transcriptPath\n }\n }\n const effectiveSessionId = payload.sessionId.length > 0 ? payload.sessionId : bindingSessionId\n const profile = (process.env.GH_ROUTER_PROFILE ?? \"\").trim().toLowerCase()\n const runtime = hookMcpRuntimeFromEnv()\n const searchEnabled = process.env.GH_ROUTER_SEARCH_ENABLED !== undefined\n ? process.env.GH_ROUTER_SEARCH_ENABLED === \"1\"\n : process.env.GH_ROUTER_ENABLE_SEMANTIC_SEARCH === \"1\"\n const bluebirdEnabled = process.env.GH_ROUTER_BLUEBIRD_ENABLED === \"1\"\n const searchTip = getPromptSearchTip(searchEnabled, bluebirdEnabled)\n const emit = async (text: string): Promise<void> => {\n if (text.trim().length === 0) return\n await new Promise<void>((resolve) => process.stdout.write(`${text}\\n`, () => resolve()))\n }\n\n // Hard gate (default-on, B1): refuse guessed-binary self-invocation.\n // Tripwire, not sandbox (the marker is env-settable) — the skill\n // wrapper always sets it; direct shell use must too.\n if (isRebriefHardGateEnabled() && !isRebriefUserInvoked()) {\n await emit(\n \"Rebrief refused: user invocation required \"\n + \"(GH_ROUTER_REBRIEF_USER_INVOKED=1). Invoke via /gh-rebrief.\",\n )\n process.exitCode = 0\n return\n }\n // Cheapest-only: point elsewhere rather than spending.\n if (!isRebriefProfileEligible(profile)) {\n await emit(\n \"Rebrief is a cheapest-profile command; this session is \"\n + `'${profile || \"unknown\"}'. Use /gh-research for grounded context instead.`,\n )\n process.exitCode = 0\n return\n }\n if (isCheapestRewriteDisabledEnv()) {\n await emit(`${searchTip}\\n\\n${PROMPT_STEER_GOAL}`)\n process.exitCode = 0\n return\n }\n if (payload.isSubagent) {\n // Fail open WITH guidance (F3): the skill must run at top level\n // (it needs the session transcript path), so say so.\n await emit(\n \"Rebrief runs at the top level only: re-invoke /gh-rebrief from your \"\n + \"own prompt, not from a subagent. No model spend occurred.\",\n )\n process.exitCode = 0\n return\n }\n // Current prompt is REQUIRED (no fallback, no silent spend): the\n // rebrief is a course correction for this specific ask.\n const refinedAsk = typeof args.ask === \"string\" ? args.ask.trim() : \"\"\n if (refinedAsk.length === 0) {\n await emit(\n \"Rebrief needs a current ask: pass one inline, e.g. \"\n + '/gh-rebrief \"<what you want next>\". No model spend occurred.',\n )\n process.exitCode = 0\n return\n }\n const stored = effectiveSessionId\n ? await fileLastPromptStore(stopReviewStateDir()).read(effectiveSessionId).catch(() => null)\n : null\n const prompt = resolveRebriefPrompt({\n ask: refinedAsk,\n hookPrompt: payload.prompt,\n storedPrompt: stored,\n })\n // Findings surface regardless (prior-turn review is never gated).\n let findingsBlock = \"\"\n if (effectiveSessionId) {\n const pending = await fileFindingsStore(stopReviewStateDir()).read(effectiveSessionId).catch(() => null)\n if (pending && pending.trim().length > 0) {\n findingsBlock =\n \"ADVISORY — independent review of your PREVIOUS change (NON-AUTHORITATIVE): an independent \"\n + \"gpt-6-luna reviewer flagged the following. Evaluate each on its merits — fix the real ones, and \"\n + \"ignore any wrong one with a one-line reason. You are NOT obligated to act on these.\\n\"\n + pending.trim()\n await fileFindingsStore(stopReviewStateDir()).clear(effectiveSessionId).catch(() => {})\n }\n }\n const joinSections = (sections: Array<string>): string =>\n sections.map((s) => s.trim()).filter((s) => s.length > 0).join(\"\\n\\n\")\n if (!isNonTrivialPrompt(prompt)) {\n await emit(joinSections([searchTip, PROMPT_STEER_GOAL, findingsBlock]))\n process.exitCode = 0\n return\n }\n if (!runtime) {\n await emit(joinSections([searchTip, PROMPT_STEER_GOAL, findingsBlock]))\n process.exitCode = 0\n return\n }\n\n // 4K intelligent context from the live transcript tail (extractive).\n const tail = readTranscriptTail(transcriptPath, REBRIEF_MAX_TAIL_LINES)\n // Last assistant text as caller context: best-effort scan of the tail\n // for an assistant text span (kept verbatim, never invented).\n let lastAssistantBrief = \"\"\n for (let i = tail.length - 1; i >= 0; i--) {\n try {\n const obj = JSON.parse(tail[i]) as {\n message?: { role?: unknown; content?: unknown }\n }\n const msg = obj.message\n if (!msg || typeof msg !== \"object\") continue\n if ((msg as { role?: unknown }).role !== \"assistant\") continue\n const content = (msg as { content?: unknown }).content\n if (typeof content === \"string\" && content.trim().length > 0) {\n lastAssistantBrief = content.trim().slice(0, 2_000)\n break\n }\n if (Array.isArray(content)) {\n for (const part of content) {\n if (\n part && typeof part === \"object\"\n && (part as { type?: unknown }).type === \"text\"\n && typeof (part as { text?: unknown }).text === \"string\"\n && ((part as { text: string }).text.trim().length > 0)\n ) {\n lastAssistantBrief = (part as { text: string }).text.trim().slice(0, 2_000)\n break\n }\n }\n if (lastAssistantBrief) break\n }\n } catch {\n /* non-JSON line — skip */\n }\n }\n const digest = buildDoneDigest(tail)\n // Layer 2: a concise Luna consult over the same tail (fail-open to the\n // deterministic digest when absent/errored). Two independent layers =\n // reproducible floor + intent-level compression.\n let lunaSummary = \"\"\n try {\n const summaryTranscript = tail.slice(-120).join(\"\\n\").slice(-12_000)\n lunaSummary = (await callInference({\n serverUrl: runtime.serverUrl,\n model: \"gpt-6-luna\",\n instructions:\n \"You are summarizing a coding session for a course correction. Answer in <=2K characters: what is done and verifiable, what is blocked/open, and what the last ask was. Extractive only — never invent facts; prefer file:line references seen in the transcript.\",\n input: `USER ASK:\\n${prompt}\\n\\nTRANSCRIPT:\\n${summaryTranscript}`,\n effort: \"high\",\n timeoutMs: INFER_TIMEOUT_MS,\n })).trim().slice(0, 2_048)\n } catch {\n lunaSummary = \"\"\n }\n const doneSoFar = [\n digest.trim().length > 0 ? `DETERMINISTIC DIGEST:\\n${digest.trim()}` : \"\",\n lunaSummary.trim().length > 0 ? `LUNA STATE SUMMARY (<=2K, advisory):\\n${lunaSummary.trim()}` : \"\",\n ]\n .filter((s) => s.length > 0)\n .join(\"\\n\\n\")\n const rebrief = buildRebriefContext({\n transcriptLines: tail,\n originalAsk: stored ?? payload.prompt,\n refinedAsk: refinedAsk,\n lastAssistantBrief,\n doneSoFar,\n })\n const statik = await (async () => {\n try {\n return buildStaticPack(workspace)\n } catch {\n return { agentsMd: \"\", claudeMd: \"\", repoStructure: \"\", verifyCommand: \"\" }\n }\n })()\n\n const result = await runCheapestRewrite({\n prompt,\n searchEnabled,\n bluebirdEnabled,\n sessionContext: rebrief.sessionContext,\n io: {\n searchCode: async (query, mode, signal) => {\n const r = await callMcpTool({\n runtime,\n group: \"search\",\n tool: \"code\",\n args: { query, workspace, mode, limit: 10, summary: false },\n timeoutMs: SEARCH_TIMEOUT_MS,\n signal,\n })\n return r.isError ? \"\" : r.text\n },\n inferSol: (system, user, signal) =>\n callInference({\n serverUrl: runtime.serverUrl,\n model: CHEAPEST_REWRITE_MODEL,\n instructions: system,\n input: user,\n effort: CHEAPEST_REWRITE_EFFORT,\n timeoutMs: INFER_TIMEOUT_MS,\n signal,\n }),\n staticPack: async () => statik,\n hasRewriteRun: async () => false,\n markRewriteRun: async () => {},\n timeoutMs: REWRITE_TIMEOUT_MS,\n buildSystemPrompt: buildRebriefSystem,\n },\n }).catch(() => ({ brief: null as string | null, timedOut: false }))\n if (result.brief && result.brief.length > 0) {\n await emit(joinSections([searchTip, result.brief, findingsBlock]))\n } else {\n // Clean miss AND timeout both fall open to the cheap regex goal here:\n // unlike the first-prompt hook there is no Luna scope path to preserve\n // spend for — the user explicitly asked for a rebrief.\n const steerEnabled = parseBoolEnv(process.env.GH_ROUTER_DISABLE_PROMPT_STEER) !== true\n await emit(joinSections([searchTip, steerEnabled ? PROMPT_STEER_GOAL : \"\", findingsBlock]))\n }\n } catch {\n /* never disrupt the session */\n }\n process.exitCode = 0\n },\n})\n"],"mappings":";;;;;;;;AAsBA,MAAa,oBAAoB;;;;;AAgCjC,SAAgB,sBAAsB,MAAqC;CACzE,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,QAAQ,WAAW,GAAG,OAAO;CACjC,IAAI;CACJ,IAAI;EACF,MAAM,KAAK,MAAM,OAAO;CAC1B,QAAQ;EAGN,OAAO,QAAQ,UAAU,MACrB;GAAE,MAAM,QAAQ,MAAM,GAAG,GAAG;GAAG,UAAU;EAAE,IAC3C;CACN;CACA,IAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GAAG,OAAO;CAClE,MAAM,MAAM;CAEZ,IAAI,IAAI,uBAAuB,KAAA,KAAa,IAAI,uBAAuB,MACrE,OAAO;CAIT,IAFa,IAAI,SAEJ,UAAU;EACrB,MAAM,MAAM,IAAI,aAAa,QACvB,OAAO,IAAI,WAAW,YAAY,IAAI,OAAO,YAAY,CAAC,CAAC,SAAS,OAAO;EACjF,MAAM,OAAO,OAAO,IAAI,WAAW,WAC/B,IAAI,SACJ,OAAO,IAAI,YAAY,WACrB,IAAI,UACJ;EACN,IAAI,KAAK,KAAK,CAAC,CAAC,WAAW,GAAG,OAAO;EACrC,OAAO;GACL,MAAM,UAAU,KAAK,KAAK,GAAA,EAA4B;GACtD,UAAU,MAAM,IAAI;EACtB;CACF;CACA,MAAM,MAAO,IAA8B;CAC3C,IAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,MAAM,Q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M;OACN,MAAM;QAAE;QAAO;QAAW;QAAM,OAAO;QAAI,SAAS;OAAM;OAC1D,WAAW;OACX;MACF,CAAC;MACD,OAAO,EAAE,UAAU,KAAK,EAAE;KAC5B;KACA,WAAW,QAAQ,MAAM,WACvB,cAAc;MACZ,WAAW,QAAQ;MACnB,OAAO;MACP,cAAc;MACd,OAAO;MACP,QAAQ;MACR,WAAW;MACX;KACF,CAAC;KACH,YAAY,YAAY;KACxB,eAAe,YAAY;KAC3B,gBAAgB,YAAY,CAAC;KAC7B,WAAW;KACX,mBAAmB;IACrB;GACF,CAAC,CAAC,CAAC,aAAa;IAAE,OAAO;IAAuB,UAAU;GAAM,EAAE;GAClE,IAAI,OAAO,SAAS,OAAO,MAAM,SAAS,GACxC,MAAM,KAAK,aAAa;IAAC;IAAW,OAAO;IAAO;GAAa,CAAC,CAAC;QAMjE,MAAM,KAAK,aAAa;IAAC;IADJ,aAAa,QAAQ,IAAI,8BAA8B,MAAM,OAC/B,oBAAoB;IAAI;GAAa,CAAC,CAAC;EAE9F,QAAQ,CAER;EACA,QAAQ,WAAW;CACrB;AACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as isSubagentContext } from "./stop-gate-policy-DQsfjnsx.js";
|
|
2
2
|
import { defineCommand } from "citty";
|
|
3
3
|
import { mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
@@ -130,4 +130,4 @@ const internalSessionBind = defineCommand({
|
|
|
130
130
|
//#endregion
|
|
131
131
|
export { internalSessionBind };
|
|
132
132
|
|
|
133
|
-
//# sourceMappingURL=internal-session-bind-
|
|
133
|
+
//# sourceMappingURL=internal-session-bind-DxdVbJ7x.js.map
|