@phren/cli 0.1.32 → 0.1.33
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/capabilities/cli.js +2 -2
- package/dist/cli/config-access.d.ts +1 -0
- package/dist/cli/config-access.js +59 -0
- package/dist/cli/config-llm.d.ts +1 -0
- package/dist/cli/config-llm.js +60 -0
- package/dist/cli/config-policy.d.ts +11 -0
- package/dist/cli/config-policy.js +328 -0
- package/dist/cli/config-proactivity.d.ts +15 -0
- package/dist/cli/config-proactivity.js +129 -0
- package/dist/cli/config-shared.d.ts +6 -0
- package/dist/cli/config-shared.js +23 -0
- package/dist/cli/config-synonyms.d.ts +1 -0
- package/dist/cli/config-synonyms.js +60 -0
- package/dist/cli/config.d.ts +6 -24
- package/dist/cli/config.js +13 -670
- package/dist/finding-graph-id.d.ts +15 -0
- package/dist/finding-graph-id.js +58 -0
- package/dist/generated/memory-ui-graph.browser.js +15 -15
- package/dist/governance/activity.d.ts +36 -0
- package/dist/governance/activity.js +83 -0
- package/dist/governance/rbac.d.ts +17 -0
- package/dist/governance/rbac.js +37 -1
- package/dist/memory-ui-graph.runtime.js +15 -15
- package/dist/phren-paths.d.ts +6 -0
- package/dist/phren-paths.js +8 -0
- package/dist/shared/governance.d.ts +1 -0
- package/dist/shared/governance.js +1 -0
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +1 -1
- package/dist/tools/config.js +39 -2
- package/dist/tools/search.js +28 -1
- package/dist/ui/data.d.ts +2 -0
- package/dist/ui/data.js +8 -3
- package/dist/ui/graph.js +2 -0
- package/dist/ui/page.js +45 -2
- package/dist/ui/scripts.d.ts +13 -0
- package/dist/ui/scripts.js +229 -2
- package/dist/ui/server.js +165 -1
- package/dist/ui/styles.d.ts +1 -0
- package/dist/ui/styles.js +38 -0
- package/package.json +1 -1
- package/dist/cli-hooks-prompt.d.ts +0 -18
- package/dist/cli-hooks-prompt.js +0 -359
- package/dist/cli-hooks-session-handlers.d.ts +0 -3
- package/dist/cli-hooks-session-handlers.js +0 -356
- package/dist/cli-hooks-stop.d.ts +0 -11
- package/dist/cli-hooks-stop.js +0 -584
- package/dist/init-bootstrap.d.ts +0 -5
- package/dist/init-bootstrap.js +0 -21
- package/dist/init-detect.d.ts +0 -8
- package/dist/init-detect.js +0 -38
- package/dist/init-env.d.ts +0 -6
- package/dist/init-env.js +0 -114
- package/dist/init-fresh.d.ts +0 -10
- package/dist/init-fresh.js +0 -234
- package/dist/init-hooks.d.ts +0 -5
- package/dist/init-hooks.js +0 -26
- package/dist/init-mcp.d.ts +0 -8
- package/dist/init-mcp.js +0 -65
- package/dist/init-modes.d.ts +0 -4
- package/dist/init-modes.js +0 -135
- package/dist/init-npm.d.ts +0 -10
- package/dist/init-npm.js +0 -37
- package/dist/init-project-local.d.ts +0 -2
- package/dist/init-project-local.js +0 -99
- package/dist/init-semantic.d.ts +0 -4
- package/dist/init-semantic.js +0 -48
- package/dist/init-types.d.ts +0 -59
- package/dist/init-types.js +0 -1
- package/dist/init-update.d.ts +0 -10
- package/dist/init-update.js +0 -96
package/dist/cli-hooks-prompt.js
DELETED
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* handleHookContext (SessionStart context injection) and handleHookTool (PostToolUse)
|
|
3
|
-
* with tool finding extraction helpers.
|
|
4
|
-
* Extracted from cli-hooks-session.ts for modularity.
|
|
5
|
-
*/
|
|
6
|
-
import { buildHookContext, debugLog, runtimeFile, sessionMarker, getPhrenPath, appendAuditLog, appendReviewQueue, detectProject, isProjectHookEnabled, getProactivityLevelForFindings, errorMessage, } from "./cli/hooks-context.js";
|
|
7
|
-
import * as fs from "fs";
|
|
8
|
-
import * as path from "path";
|
|
9
|
-
import { buildIndex, queryRows, } from "./shared/index.js";
|
|
10
|
-
import { filterTaskByPriority } from "./shared/retrieval.js";
|
|
11
|
-
import { readStdinJson, getSessionCap } from "./cli-hooks-stop.js";
|
|
12
|
-
import { logger } from "./logger.js";
|
|
13
|
-
export async function handleHookContext() {
|
|
14
|
-
const ctx = buildHookContext();
|
|
15
|
-
if (!ctx.hooksEnabled) {
|
|
16
|
-
process.exit(0);
|
|
17
|
-
}
|
|
18
|
-
let cwd = ctx.cwd;
|
|
19
|
-
const ctxStdin = readStdinJson();
|
|
20
|
-
if (ctxStdin?.cwd)
|
|
21
|
-
cwd = ctxStdin.cwd;
|
|
22
|
-
const project = cwd !== ctx.cwd ? detectProject(ctx.phrenPath, cwd, ctx.profile) : ctx.activeProject;
|
|
23
|
-
if (!isProjectHookEnabled(ctx.phrenPath, project, "UserPromptSubmit")) {
|
|
24
|
-
process.exit(0);
|
|
25
|
-
}
|
|
26
|
-
const db = await buildIndex(ctx.phrenPath, ctx.profile);
|
|
27
|
-
const contextLabel = project ? `\u25c6 phren \u00b7 ${project} \u00b7 context` : `\u25c6 phren \u00b7 context`;
|
|
28
|
-
const parts = [contextLabel, "<phren-context>"];
|
|
29
|
-
if (project) {
|
|
30
|
-
const summaryRow = queryRows(db, "SELECT content FROM docs WHERE project = ? AND type = 'summary'", [project]);
|
|
31
|
-
if (summaryRow) {
|
|
32
|
-
parts.push(`# ${project}`);
|
|
33
|
-
parts.push(summaryRow[0][0]);
|
|
34
|
-
parts.push("");
|
|
35
|
-
}
|
|
36
|
-
const findingsRow = queryRows(db, "SELECT content FROM docs WHERE project = ? AND type = 'findings'", [project]);
|
|
37
|
-
if (findingsRow) {
|
|
38
|
-
const content = findingsRow[0][0];
|
|
39
|
-
const bullets = content.split("\n")
|
|
40
|
-
.filter(l => l.startsWith("- "))
|
|
41
|
-
.filter(l => !(/<!--\s*superseded_by:/.test(l) || /<!--\s*(?:phren:)?retract/.test(l) || /status\s+"retracted"/.test(l) || /status\s+"superseded"/.test(l)))
|
|
42
|
-
.slice(0, 10);
|
|
43
|
-
if (bullets.length > 0) {
|
|
44
|
-
parts.push("## Recent findings");
|
|
45
|
-
parts.push(bullets.join("\n"));
|
|
46
|
-
parts.push("");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const taskRow = queryRows(db, "SELECT content FROM docs WHERE project = ? AND type = 'task'", [project]);
|
|
50
|
-
if (taskRow) {
|
|
51
|
-
const content = taskRow[0][0];
|
|
52
|
-
const activeItems = content.split("\n").filter(l => l.startsWith("- "));
|
|
53
|
-
const filtered = filterTaskByPriority(activeItems);
|
|
54
|
-
const trimmed = filtered.slice(0, 5);
|
|
55
|
-
if (trimmed.length > 0) {
|
|
56
|
-
parts.push("## Active tasks");
|
|
57
|
-
parts.push(trimmed.join("\n"));
|
|
58
|
-
parts.push("");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const projectRows = queryRows(db, "SELECT DISTINCT project FROM docs ORDER BY project", []);
|
|
64
|
-
if (projectRows) {
|
|
65
|
-
parts.push("# Phren projects");
|
|
66
|
-
parts.push(projectRows.map(r => `- ${r[0]}`).join("\n"));
|
|
67
|
-
parts.push("");
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
parts.push("</phren-context>");
|
|
71
|
-
if (parts.length > 2) {
|
|
72
|
-
console.log(parts.join("\n"));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// ── PostToolUse hook ─────────────────────────────────────────────────────────
|
|
76
|
-
const INTERESTING_TOOLS = new Set(["Read", "Write", "Edit", "Bash", "Glob", "Grep"]);
|
|
77
|
-
const COOLDOWN_MS = parseInt(process.env.PHREN_AUTOCAPTURE_COOLDOWN_MS ?? "30000", 10);
|
|
78
|
-
const MAX_TOOL_COMMAND_LENGTH = 200;
|
|
79
|
-
function flattenToolResponseText(value, maxChars = 4000) {
|
|
80
|
-
if (typeof value === "string")
|
|
81
|
-
return value;
|
|
82
|
-
const queue = [value];
|
|
83
|
-
const parts = [];
|
|
84
|
-
let length = 0;
|
|
85
|
-
while (queue.length > 0 && length < maxChars) {
|
|
86
|
-
const current = queue.shift();
|
|
87
|
-
if (typeof current === "string") {
|
|
88
|
-
const trimmed = current.trim();
|
|
89
|
-
if (!trimmed)
|
|
90
|
-
continue;
|
|
91
|
-
parts.push(trimmed);
|
|
92
|
-
length += trimmed.length + 1;
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
if (Array.isArray(current)) {
|
|
96
|
-
queue.unshift(...current);
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
if (current && typeof current === "object") {
|
|
100
|
-
queue.unshift(...Object.values(current));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (parts.length > 0)
|
|
104
|
-
return parts.join("\n").slice(0, maxChars);
|
|
105
|
-
return JSON.stringify(value ?? "").slice(0, maxChars);
|
|
106
|
-
}
|
|
107
|
-
export async function handleHookTool() {
|
|
108
|
-
const ctx = buildHookContext();
|
|
109
|
-
if (!ctx.hooksEnabled) {
|
|
110
|
-
process.exit(0);
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
113
|
-
const start = Date.now();
|
|
114
|
-
let raw = "";
|
|
115
|
-
if (!process.stdin.isTTY) {
|
|
116
|
-
try {
|
|
117
|
-
raw = fs.readFileSync(0, "utf-8");
|
|
118
|
-
}
|
|
119
|
-
catch (err) {
|
|
120
|
-
logger.debug("hookTool stdinRead", errorMessage(err));
|
|
121
|
-
process.exit(0);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
let data;
|
|
125
|
-
try {
|
|
126
|
-
data = JSON.parse(raw);
|
|
127
|
-
}
|
|
128
|
-
catch (err) {
|
|
129
|
-
logger.debug("hookTool stdinParse", errorMessage(err));
|
|
130
|
-
process.exit(0);
|
|
131
|
-
}
|
|
132
|
-
const toolName = String(data.tool_name ?? data.tool ?? "");
|
|
133
|
-
if (!INTERESTING_TOOLS.has(toolName)) {
|
|
134
|
-
process.exit(0);
|
|
135
|
-
}
|
|
136
|
-
const sessionId = data.session_id;
|
|
137
|
-
const input = (data.tool_input ?? {});
|
|
138
|
-
const entry = {
|
|
139
|
-
at: new Date().toISOString(),
|
|
140
|
-
session_id: sessionId,
|
|
141
|
-
tool: toolName,
|
|
142
|
-
};
|
|
143
|
-
if (toolName === "Read" || toolName === "Write" || toolName === "Edit") {
|
|
144
|
-
const filePath = input.file_path ?? input.path ?? undefined;
|
|
145
|
-
if (filePath)
|
|
146
|
-
entry.file = String(filePath);
|
|
147
|
-
}
|
|
148
|
-
else if (toolName === "Bash") {
|
|
149
|
-
const cmd = input.command ?? undefined;
|
|
150
|
-
if (cmd)
|
|
151
|
-
entry.command = String(cmd).slice(0, MAX_TOOL_COMMAND_LENGTH);
|
|
152
|
-
}
|
|
153
|
-
else if (toolName === "Glob") {
|
|
154
|
-
const pattern = input.pattern ?? undefined;
|
|
155
|
-
if (pattern)
|
|
156
|
-
entry.file = String(pattern);
|
|
157
|
-
}
|
|
158
|
-
else if (toolName === "Grep") {
|
|
159
|
-
const pattern = input.pattern ?? undefined;
|
|
160
|
-
const searchPath = input.path ?? undefined;
|
|
161
|
-
if (pattern)
|
|
162
|
-
entry.command = `grep ${pattern}${searchPath ? ` in ${searchPath}` : ""}`.slice(0, MAX_TOOL_COMMAND_LENGTH);
|
|
163
|
-
}
|
|
164
|
-
const responseStr = flattenToolResponseText(data.tool_response ?? "");
|
|
165
|
-
if (/(error|exception|failed|no such file|ENOENT)/i.test(responseStr)) {
|
|
166
|
-
entry.error = responseStr.slice(0, 300);
|
|
167
|
-
}
|
|
168
|
-
const cwd = (data.cwd ?? input.cwd ?? undefined);
|
|
169
|
-
let activeProject = cwd ? detectProject(ctx.phrenPath, cwd, ctx.profile) : null;
|
|
170
|
-
if (!isProjectHookEnabled(ctx.phrenPath, activeProject, "PostToolUse")) {
|
|
171
|
-
appendAuditLog(ctx.phrenPath, "hook_tool", `status=project_disabled project=${activeProject}`);
|
|
172
|
-
process.exit(0);
|
|
173
|
-
}
|
|
174
|
-
try {
|
|
175
|
-
const logFile = runtimeFile(ctx.phrenPath, "tool-log.jsonl");
|
|
176
|
-
fs.mkdirSync(path.dirname(logFile), { recursive: true });
|
|
177
|
-
fs.appendFileSync(logFile, JSON.stringify(entry) + "\n");
|
|
178
|
-
}
|
|
179
|
-
catch (err) {
|
|
180
|
-
logger.debug("hookTool toolLog", errorMessage(err));
|
|
181
|
-
}
|
|
182
|
-
const cooldownFile = runtimeFile(ctx.phrenPath, "hook-tool-cooldown");
|
|
183
|
-
try {
|
|
184
|
-
if (fs.existsSync(cooldownFile)) {
|
|
185
|
-
const age = Date.now() - fs.statSync(cooldownFile).mtimeMs;
|
|
186
|
-
if (age < COOLDOWN_MS) {
|
|
187
|
-
debugLog(`hook-tool: cooldown active (${Math.round(age / 1000)}s < ${Math.round(COOLDOWN_MS / 1000)}s), skipping extraction`);
|
|
188
|
-
activeProject = null;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
catch (err) {
|
|
193
|
-
logger.debug("hookTool cooldownStat", errorMessage(err));
|
|
194
|
-
}
|
|
195
|
-
if (activeProject && sessionId) {
|
|
196
|
-
try {
|
|
197
|
-
const capFile = sessionMarker(ctx.phrenPath, `tool-findings-${sessionId}`);
|
|
198
|
-
let count = 0;
|
|
199
|
-
if (fs.existsSync(capFile)) {
|
|
200
|
-
count = Number.parseInt(fs.readFileSync(capFile, "utf8").trim(), 10) || 0;
|
|
201
|
-
}
|
|
202
|
-
const sessionCap = getSessionCap();
|
|
203
|
-
if (count >= sessionCap) {
|
|
204
|
-
debugLog(`hook-tool: session cap reached (${count}/${sessionCap}), skipping extraction`);
|
|
205
|
-
activeProject = null;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
catch (err) {
|
|
209
|
-
logger.debug("hookTool sessionCapCheck", errorMessage(err));
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
const findingsLevelForTool = getProactivityLevelForFindings(ctx.phrenPath);
|
|
213
|
-
if (activeProject && findingsLevelForTool !== "low") {
|
|
214
|
-
try {
|
|
215
|
-
const candidates = filterToolFindingsForProactivity(extractToolFindings(toolName, input, responseStr, data.tool_response), findingsLevelForTool);
|
|
216
|
-
for (const { text, confidence } of candidates) {
|
|
217
|
-
appendReviewQueue(ctx.phrenPath, activeProject, "Review", [text]);
|
|
218
|
-
debugLog(`hook-tool: queued candidate for review (conf=${confidence}): ${text.slice(0, 60)}`);
|
|
219
|
-
}
|
|
220
|
-
if (candidates.length > 0) {
|
|
221
|
-
try {
|
|
222
|
-
fs.writeFileSync(cooldownFile, Date.now().toString());
|
|
223
|
-
}
|
|
224
|
-
catch (err) {
|
|
225
|
-
logger.debug("hookTool cooldownWrite", errorMessage(err));
|
|
226
|
-
}
|
|
227
|
-
if (sessionId) {
|
|
228
|
-
try {
|
|
229
|
-
const capFile = sessionMarker(ctx.phrenPath, `tool-findings-${sessionId}`);
|
|
230
|
-
let count = 0;
|
|
231
|
-
try {
|
|
232
|
-
count = Number.parseInt(fs.readFileSync(capFile, "utf8").trim(), 10) || 0;
|
|
233
|
-
}
|
|
234
|
-
catch (err) {
|
|
235
|
-
logger.debug("hookTool capFileRead", errorMessage(err));
|
|
236
|
-
}
|
|
237
|
-
count += candidates.length;
|
|
238
|
-
fs.writeFileSync(capFile, count.toString());
|
|
239
|
-
}
|
|
240
|
-
catch (err) {
|
|
241
|
-
logger.debug("hookTool capFileWrite", errorMessage(err));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
catch (err) {
|
|
247
|
-
debugLog(`hook-tool: finding extraction failed: ${errorMessage(err)}`);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
else if (activeProject) {
|
|
251
|
-
debugLog("hook-tool: skipped because findings proactivity is low");
|
|
252
|
-
}
|
|
253
|
-
const elapsed = Date.now() - start;
|
|
254
|
-
debugLog(`hook-tool: ${toolName} logged in ${elapsed}ms`);
|
|
255
|
-
process.exit(0);
|
|
256
|
-
}
|
|
257
|
-
catch (err) {
|
|
258
|
-
debugLog(`hook-tool: unhandled error: ${err instanceof Error ? err.stack || err.message : String(err)}`);
|
|
259
|
-
process.exit(0);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
// Negative lookahead `(?!\(|\[)` rejects markdown link/reference patterns:
|
|
263
|
-
// [Architecture](#architecture) ← TOC anchor, content was being captured as "(#architecture)"
|
|
264
|
-
// [bug][1] ← markdown reference link, content was being captured as "[1]"
|
|
265
|
-
// produced garbage review-queue entries like "[architecture] (#architecture)".
|
|
266
|
-
const EXPLICIT_TAG_PATTERN = /\[(pitfall|decision|pattern|tradeoff|architecture|bug)\](?!\(|\[)\s*(.+)/i;
|
|
267
|
-
export function filterToolFindingsForProactivity(candidates, level = getProactivityLevelForFindings(getPhrenPath())) {
|
|
268
|
-
if (level === "high")
|
|
269
|
-
return candidates;
|
|
270
|
-
if (level === "low")
|
|
271
|
-
return [];
|
|
272
|
-
return candidates.filter((candidate) => candidate.explicit === true);
|
|
273
|
-
}
|
|
274
|
-
// Bash commands whose non-zero exit codes are routine signal, not bugs.
|
|
275
|
-
// grep/rg/ag/find returning exit 1 (no match) is the common case; conditional
|
|
276
|
-
// shell tests evaluating false is another. Don't surface these as findings.
|
|
277
|
-
const NOISY_BASH_COMMAND_PATTERNS = [
|
|
278
|
-
/^\s*(?:grep|rg|ag|ack)\b/,
|
|
279
|
-
/^\s*find\b/,
|
|
280
|
-
/^\s*which\b/,
|
|
281
|
-
/^\s*command\s+-v\b/,
|
|
282
|
-
/^\s*test\b/,
|
|
283
|
-
/^\s*\[\s/,
|
|
284
|
-
/^\s*\[\[\s/,
|
|
285
|
-
/^\s*pgrep\b/,
|
|
286
|
-
/^\s*pkill\b/,
|
|
287
|
-
/^\s*git\s+diff\s+--quiet/,
|
|
288
|
-
];
|
|
289
|
-
function isNoisyBashCommand(cmd) {
|
|
290
|
-
if (/\|\|\s*true\b/.test(cmd))
|
|
291
|
-
return true;
|
|
292
|
-
if (/2>\s*\/dev\/null/.test(cmd))
|
|
293
|
-
return true;
|
|
294
|
-
return NOISY_BASH_COMMAND_PATTERNS.some((re) => re.test(cmd));
|
|
295
|
-
}
|
|
296
|
-
function extractToolErrorSignal(toolResponse) {
|
|
297
|
-
if (!toolResponse || typeof toolResponse !== "object") {
|
|
298
|
-
return { isError: false, hasExitCode: false };
|
|
299
|
-
}
|
|
300
|
-
const tr = toolResponse;
|
|
301
|
-
const isError = Boolean(tr.is_error ?? tr.isError);
|
|
302
|
-
const rawExit = tr.exit_code ?? tr.exitCode;
|
|
303
|
-
const exitCode = typeof rawExit === "number" ? rawExit : undefined;
|
|
304
|
-
return { isError, exitCode, hasExitCode: exitCode !== undefined };
|
|
305
|
-
}
|
|
306
|
-
export function extractToolFindings(toolName, input, responseStr, toolResponse) {
|
|
307
|
-
const candidates = [];
|
|
308
|
-
const changedContent = (toolName === "Edit" || toolName === "Write")
|
|
309
|
-
? String(input.new_string ?? input.content ?? "")
|
|
310
|
-
: "";
|
|
311
|
-
const explicitSource = changedContent || responseStr;
|
|
312
|
-
const tagMatches = explicitSource.matchAll(new RegExp(EXPLICIT_TAG_PATTERN.source, "gi"));
|
|
313
|
-
for (const m of tagMatches) {
|
|
314
|
-
const tag = m[1].toLowerCase();
|
|
315
|
-
const content = m[2].replace(/\s+/g, " ").trim().slice(0, 200);
|
|
316
|
-
if (content) {
|
|
317
|
-
candidates.push({ text: `[${tag}] ${content}`, confidence: 0.85, explicit: true });
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
if (toolName === "Edit" || toolName === "Write") {
|
|
321
|
-
const filePath = String(input.file_path ?? input.path ?? "unknown");
|
|
322
|
-
const filename = path.basename(filePath);
|
|
323
|
-
if (/\b(TODO|FIXME)\b/.test(changedContent)) {
|
|
324
|
-
const firstLine = changedContent.split("\n").find((l) => /\b(TODO|FIXME)\b/.test(l));
|
|
325
|
-
if (firstLine) {
|
|
326
|
-
candidates.push({
|
|
327
|
-
text: `[pitfall] ${filename}: ${firstLine.trim().slice(0, 150)}`,
|
|
328
|
-
confidence: 0.45,
|
|
329
|
-
explicit: false,
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
// (Removed: try/catch additions used to emit "[pitfall] ... error handling added near ..."
|
|
334
|
-
// candidates. Adding error handling is normal code, not a pitfall — the heuristic produced
|
|
335
|
-
// ~21 false positives for every real one in observed stores. If we ever need this back,
|
|
336
|
-
// gate on a *removed* try/catch, not an added one.)
|
|
337
|
-
}
|
|
338
|
-
if (toolName === "Bash") {
|
|
339
|
-
const fullCmd = String(input.command ?? "");
|
|
340
|
-
const cmdShort = fullCmd.slice(0, 30);
|
|
341
|
-
const errorSignal = extractToolErrorSignal(toolResponse);
|
|
342
|
-
// Only emit a [bug] candidate when (a) we have a definite error signal from the tool
|
|
343
|
-
// result (is_error or non-zero exit_code) and (b) the command isn't a known-noisy one
|
|
344
|
-
// like grep/find/test where exit 1 just means "didn't match" rather than a failure.
|
|
345
|
-
const hasDefiniteError = errorSignal.isError || (errorSignal.hasExitCode && (errorSignal.exitCode ?? 0) !== 0);
|
|
346
|
-
if (hasDefiniteError && cmdShort && !isNoisyBashCommand(fullCmd)) {
|
|
347
|
-
const firstErrorLine = responseStr.split("\n").find((l) => /(error|exception|failed|ENOENT|command not found|permission denied)/i.test(l));
|
|
348
|
-
const detail = (firstErrorLine ?? responseStr.split("\n")[0] ?? "").trim().slice(0, 150);
|
|
349
|
-
if (detail) {
|
|
350
|
-
candidates.push({
|
|
351
|
-
text: `[bug] command '${cmdShort}' failed: ${detail}`,
|
|
352
|
-
confidence: 0.55,
|
|
353
|
-
explicit: false,
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
return candidates;
|
|
359
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare function getUntrackedProjectNotice(phrenPath: string, cwd: string): string | null;
|
|
2
|
-
export declare function getSessionStartOnboardingNotice(phrenPath: string, cwd: string, activeProject: string | null): string | null;
|
|
3
|
-
export declare function handleHookSessionStart(): Promise<void>;
|