hydra-nano 0.3.0 → 0.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hydra-nano",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Small local models that take the noisy work off your coding agent: git history, test and build digests and OS inspection run on your machine, and only the lines that matter reach Claude Code, Codex, Cursor, OpenCode, Gemini CLI or Antigravity. Skill, MCP server and hooks.",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -247,7 +247,8 @@ function improve(args) {
247
247
  for (const row of h.costMoreExamples) lines.push(` cost more: ${row.question.slice(0, 80)} (${row.raw} -> ${row.returned})`);
248
248
  }
249
249
  for (const [agent, a] of Object.entries(report.agents)) {
250
- lines.push(`agent ${agent}: ${a.calls} calls (${a.viaMcp} through MCP), ${a.denials} runs turned back, ${a.sessions} sessions started`);
250
+ const apps = Object.entries(a.fromApps ?? {}).map(([app, n]) => `, ${n} from ${app}`).join('');
251
+ lines.push(`agent ${agent}: ${a.calls} calls (${a.viaMcp} through MCP${apps}), ${a.denials} runs turned back, ${a.sessions} sessions started`);
251
252
  }
252
253
  const { denials, followedByHydra, trimmed, rawBypasses } = report.hooks;
253
254
  const { decisions, p50Ms, p90Ms } = report.hooks;
@@ -44,6 +44,9 @@ const historyRequest = question => /\b(?:commits?|history|evolved|over time|git
44
44
  // "with timeout in their subjects", "messages mentioning cache"
45
45
  const subjectTerm = question => (question.match(/\bwith\s+["'`]?([\w.-]+)["'`]?\s+in\s+(?:their|the|its)\s+(?:subjects?|messages?|titles?)\b/i)
46
46
  ?? question.match(/\b(?:subjects?|messages?)\s+(?:containing|mentioning|that mention|with)\s+["'`]?([\w.-]+)/i))?.[1];
47
+ // "messages that mention main": the question searches message text for this word.
48
+ const searchesFor = (question, term) => subjectTerm(question)?.toLowerCase() === term.toLowerCase()
49
+ || new RegExp(`\\b(?:mention\\w*|contain\\w*|says?|saying)\\s+["'\`]?${term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\w.-])`, 'i').test(question);
47
50
  // The first word of the question that is a file inside the repository, e.g. src/app.ts or Makefile.
48
51
  function fileInQuestion(question, cwd) {
49
52
  for (const word of question.split(/\s+/)) {
@@ -208,6 +211,9 @@ async function clean(p, question, cwd) {
208
211
  // Preserve compound filtering only when the question also asks about messages.
209
212
  const asksMessage = /\b(?:messages?|subjects?|mention\w*)\b/i.test(question);
210
213
  if (safe(p.grep) && (asksMessage || (!a.path && !a.author))) a.grep = p.grep.trim();
214
+ // A branch or tag named in the question ("between v0.2.0 and main") is a range end, not message text.
215
+ if (a.grep && !searchesFor(question, a.grep)
216
+ && (await git(cwd, ['rev-parse', '--verify', '--quiet', `${a.grep}^{commit}`])).ok) delete a.grep;
211
217
  if (p.probe === 'log' && !a.grep && subjectTerm(question)) a.grep = subjectTerm(question);
212
218
  for (const key of ['rev', 'base']) {
213
219
  // HEAD as a base compares HEAD with itself and always shows nothing.
@@ -27,8 +27,10 @@ export function caller(session = process.env.CLAUDE_CODE_SESSION_ID) {
27
27
  const detail = process.env.HYDRA_AGENT || process.env.AI_AGENT || (process.env.CLAUDECODE ? undefined : app);
28
28
  const agent = process.env.HYDRA_AGENT ? detail.toLowerCase().replace(/[-_ ]?mcp[-_ ]?client$/, '')
29
29
  : process.env.AI_AGENT ? detail.split('_')[0] : process.env.CLAUDECODE ? 'claude-code' : app ? 'antigravity' : 'shell';
30
+ // An app that starts the agent for you (T3 Code runs Claude Code, Codex, ...) is kept apart from the agent itself.
31
+ const launcher = process.env.__CFBundleIdentifier === 'com.t3tools.t3code' || process.env.T3CODE_HOME ? 't3code' : undefined;
30
32
  return { agent, ...(detail ? { agentDetail: detail } : {}), ...(process.env.HYDRA_VIA ? { via: process.env.HYDRA_VIA } : {}),
31
- ...(session ? { session } : {}) };
33
+ ...(launcher ? { app: launcher } : {}), ...(session ? { session } : {}) };
32
34
  }
33
35
 
34
36
  export function record(entry) {
@@ -118,8 +120,9 @@ export function findings(all = rows(), { since } = {}) {
118
120
  && call.head === 'test' && call.ts >= deny.ts && Date.parse(call.ts) - Date.parse(deny.ts) <= 5 * 60_000));
119
121
  const agents = {};
120
122
  for (const row of recent) {
121
- const agent = agents[row.agent ?? 'unknown'] ??= { calls: 0, viaMcp: 0, denials: 0, sessions: 0 };
123
+ const agent = agents[row.agent ?? 'unknown'] ??= { calls: 0, viaMcp: 0, denials: 0, sessions: 0, fromApps: {} };
122
124
  if (isCall(row)) { agent.calls += 1; if (row.via === 'mcp') agent.viaMcp += 1; }
125
+ if (isCall(row) && row.app) agent.fromApps[row.app] = (agent.fromApps[row.app] ?? 0) + 1;
123
126
  if (row.kind === 'hook' && row.decision === 'deny') agent.denials += 1;
124
127
  if (row.kind === 'session') agent.sessions += 1;
125
128
  }