@phren/cli 0.1.52 → 0.1.53

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.
Files changed (2) hide show
  1. package/dist/cli/hooks.js +31 -1
  2. package/package.json +1 -1
package/dist/cli/hooks.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // cli-hooks-output.ts — hook output formatting
6
6
  // cli-hooks-globs.ts — project glob matching
7
7
  import { debugLog, sessionMarker, sessionsDir, getPhrenPath, } from "../shared.js";
8
- import { mergeConfig, } from "../shared/governance.js";
8
+ import { mergeConfig, recordLookupEvents } from "../shared/governance.js";
9
9
  import { loadIndexForHook, detectProject, } from "../shared/index.js";
10
10
  import { isProjectHookEnabled } from "../project-config.js";
11
11
  import { checkConsolidationNeeded, } from "../shared/content.js";
@@ -37,6 +37,7 @@ import { getGitContext, trackSessionMetrics, } from "./hooks-session.js";
37
37
  import { approximateTokens, SNIPPET_OVERHEAD_TOKENS } from "../shared/retrieval.js";
38
38
  import { resolveRuntimeProfile } from "../runtime-profile.js";
39
39
  import { handleTaskPromptLifecycle } from "../task/lifecycle.js";
40
+ import { bestFindingNodeId } from "../finding-graph-id.js";
40
41
  // Auto-learn from prompts was removed — it learned conversational noise ("bro", "idk", typos)
41
42
  // as synonyms for high-frequency terms. Manual `phren config synonyms add` still works.
42
43
  // Future: finding-based co-occurrence mining (phren maintain command, not live hook).
@@ -227,6 +228,35 @@ export async function handleHookPrompt() {
227
228
  budgetUsedTokens = runningTokens;
228
229
  debugLog(`injection-budget: trimmed ${selected.length} -> ${kept.length} snippets to fit ${maxInjectTokens} token budget`);
229
230
  }
231
+ // Live activity: what a prompt pulled in is a recall as much as a search
232
+ // hit is, and it is by far the most common kind. Recording it here is what
233
+ // lets the terminal graph's watch mode, and anything else tailing the log,
234
+ // light up while an agent works. Best-effort: logging must never break
235
+ // the hook.
236
+ try {
237
+ const at = new Date().toISOString();
238
+ // The prompt, not the expanded keyword string: the feed shows this to a
239
+ // person, and "retry retry backoff backoff jitter" is not what they asked.
240
+ const asked = prompt.replace(/\s+/g, " ").trim().slice(0, 160);
241
+ recordLookupEvents(getPhrenPath(), budgetSelected.map((s) => {
242
+ const nodeId = s.doc.type === "findings" ? bestFindingNodeId(s.doc.project, s.doc.content, keywords) : null;
243
+ return {
244
+ at,
245
+ query: asked,
246
+ project: s.doc.project,
247
+ filename: s.doc.filename,
248
+ type: s.doc.type,
249
+ path: s.doc.path,
250
+ snippet: s.snippet,
251
+ source: "hook",
252
+ ...(nodeId ? { nodeId } : {}),
253
+ ...(sessionId ? { session: sessionId } : {}),
254
+ };
255
+ }));
256
+ }
257
+ catch (err) {
258
+ debugLog(`hook-prompt lookup-events: ${errorMessage(err)}`);
259
+ }
230
260
  const parts = buildHookOutput(budgetSelected, budgetUsedTokens, intent, gitCtx, detectedProject, stage, safeTokenBudget, getPhrenPath(), sessionId);
231
261
  const taskLevel = resolvedConfig.proactivity.tasks
232
262
  ?? resolvedConfig.proactivity.base
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phren/cli",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
4
4
  "description": "Knowledge layer for AI agents — CLI, MCP server, and data layer",
5
5
  "type": "module",
6
6
  "bin": {