eminiar 0.13.3 → 0.13.5

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/hook.js CHANGED
@@ -35,7 +35,7 @@ import {
35
35
  swarmSubagentStop,
36
36
  swarmTouch,
37
37
  workerLacksTool
38
- } from "./hook-chunk-ZLRLOPLR.js";
38
+ } from "./hook-chunk-RE4WT5D3.js";
39
39
  import {
40
40
  GUIDE_ORDER,
41
41
  classifyAssistant,
@@ -50,9 +50,10 @@ import {
50
50
  getStorage,
51
51
  init_esm_shims,
52
52
  projectDir,
53
+ sessionContext,
53
54
  setStorageBusyTimeout,
54
55
  withPriority
55
- } from "./hook-chunk-ETYHCPPH.js";
56
+ } from "./hook-chunk-G7UP4ZVA.js";
56
57
 
57
58
  // src/hook.ts
58
59
  init_esm_shims();
@@ -1834,7 +1835,7 @@ function persist(db, sessionId, events) {
1834
1835
  }
1835
1836
  }
1836
1837
  function open(input) {
1837
- const ctx = getContext(input.cwd);
1838
+ const ctx = sessionContext(input.cwd);
1838
1839
  const db = getStorage(ctx, { vectors: false });
1839
1840
  const sessionId = input.session_id || "unknown";
1840
1841
  db.sessionUpsert({
@@ -1847,7 +1848,7 @@ function open(input) {
1847
1848
  var usageFailureLogged = false;
1848
1849
  function ingestUsage(db, input, sessionId) {
1849
1850
  try {
1850
- const ctx = getContext(input.cwd);
1851
+ const ctx = sessionContext(input.cwd);
1851
1852
  if (!usageEnabled(ctx)) return;
1852
1853
  const overrides = ctx.config.usage.pricing;
1853
1854
  ingestSession(db, ctx.root, sessionId, input.transcript_path, { overrides });
@@ -1864,7 +1865,7 @@ function ingestUsage(db, input, sessionId) {
1864
1865
  }
1865
1866
  var userPromptSubmit = async (input) => {
1866
1867
  if (!input.prompt?.trim()) return void 0;
1867
- const ctx = getContext(input.cwd);
1868
+ const ctx = sessionContext(input.cwd);
1868
1869
  const db = getStorage(ctx, { vectors: false });
1869
1870
  const sessionId = input.session_id || "unknown";
1870
1871
  try {
@@ -1901,7 +1902,7 @@ var userPromptSubmit = async (input) => {
1901
1902
  let systemMessage;
1902
1903
  if (ctx.config.adjudicator.enabled && input.client !== "cursor" && hasBudget(ADJUDICATOR_NEEDS_MS)) {
1903
1904
  try {
1904
- const { onPrompt } = await import("./hook-hooks-5U2AI6W7.js");
1905
+ const { onPrompt } = await import("./hook-hooks-5H6LFYD5.js");
1905
1906
  const a = await onPrompt(ctx, db, input, sessionId);
1906
1907
  if (a?.context) parts.push(a.context);
1907
1908
  systemMessage = a?.systemMessage;
@@ -1936,9 +1937,9 @@ function detectLoop(db, sessionId, key, summary) {
1936
1937
  }
1937
1938
  var postToolUse = async (input) => {
1938
1939
  if (!input.tool_name) return void 0;
1939
- if (input.agent_id) swarmActivity(getContext(input.cwd), input, false);
1940
+ if (input.agent_id) swarmActivity(sessionContext(input.cwd), input, false);
1940
1941
  const isAgent = input.tool_name === "Agent" || input.tool_name === "Task";
1941
- if (isAgent) swarmAgentReturned(getContext(input.cwd), input);
1942
+ if (isAgent) swarmAgentReturned(sessionContext(input.cwd), input);
1942
1943
  const { db, root, sessionId } = open(input);
1943
1944
  const drafts = classifyToolCall({
1944
1945
  toolName: input.tool_name,
@@ -1956,10 +1957,10 @@ var postToolUse = async (input) => {
1956
1957
  }
1957
1958
  }
1958
1959
  if (isAgent && input.client !== "cursor") {
1959
- const ctx = getContext(input.cwd);
1960
+ const ctx = sessionContext(input.cwd);
1960
1961
  if (ctx.config.adjudicator.enabled) {
1961
1962
  try {
1962
- const { onPostAgent } = await import("./hook-hooks-5U2AI6W7.js");
1963
+ const { onPostAgent } = await import("./hook-hooks-5H6LFYD5.js");
1963
1964
  onPostAgent(ctx, db, input);
1964
1965
  } catch {
1965
1966
  }
@@ -1988,7 +1989,7 @@ function bestEffortWrites(db) {
1988
1989
  }
1989
1990
  var postToolUseFailure = async (input) => {
1990
1991
  if (!input.tool_name) return void 0;
1991
- const ctx = getContext(input.cwd);
1992
+ const ctx = sessionContext(input.cwd);
1992
1993
  if (input.tool_name === "Agent" || input.tool_name === "Task") swarmAgentReturned(ctx, input);
1993
1994
  const db = getStorage(ctx, { vectors: false });
1994
1995
  const sessionId = input.session_id || "unknown";
@@ -2028,7 +2029,7 @@ var postToolUseFailure = async (input) => {
2028
2029
  return recalled ? { hookSpecificOutput: { hookEventName: "PostToolUseFailure", additionalContext: recalled } } : void 0;
2029
2030
  };
2030
2031
  var subagentStop = (input) => {
2031
- if (input.agent_id) swarmSubagentStop(getContext(input.cwd), input);
2032
+ if (input.agent_id) swarmSubagentStop(sessionContext(input.cwd), input);
2032
2033
  const { db, sessionId } = open(input);
2033
2034
  const msg = input.last_assistant_message ?? "";
2034
2035
  if (msg.trim()) {
@@ -2054,7 +2055,7 @@ var stop = (input) => {
2054
2055
  return void 0;
2055
2056
  };
2056
2057
  var sessionEnd = async (input) => {
2057
- const ctx = getContext(input.cwd);
2058
+ const ctx = sessionContext(input.cwd);
2058
2059
  swarmSessionEnd(ctx, input);
2059
2060
  const { db, sessionId } = open(input);
2060
2061
  db.sessionUpsert({ id: sessionId, ended_at: Date.now() });
@@ -2064,7 +2065,7 @@ var sessionEnd = async (input) => {
2064
2065
  ingestUsage(db, input, sessionId);
2065
2066
  if (ctx.config.adjudicator.enabled && input.client !== "cursor") {
2066
2067
  try {
2067
- const { onSessionEnd } = await import("./hook-hooks-5U2AI6W7.js");
2068
+ const { onSessionEnd } = await import("./hook-hooks-5H6LFYD5.js");
2068
2069
  onSessionEnd(ctx, db, input);
2069
2070
  } catch {
2070
2071
  }
@@ -2186,7 +2187,7 @@ function renderGuide(db, sessionId, budget = 2048) {
2186
2187
  // src/hooks/pre-compact.ts
2187
2188
  var SNAPSHOT_BUDGET = 2048;
2188
2189
  var preCompact = (input) => {
2189
- const ctx = getContext(input.cwd);
2190
+ const ctx = sessionContext(input.cwd);
2190
2191
  const db = getStorage(ctx, { vectors: false });
2191
2192
  const sessionId = input.session_id || "unknown";
2192
2193
  const body = renderGuide(db, sessionId, SNAPSHOT_BUDGET);
@@ -3497,12 +3498,14 @@ function fileKnowledge(ctx, input) {
3497
3498
  return void 0;
3498
3499
  }
3499
3500
  }
3500
- function commitFiles(root, cmd) {
3501
- const list = (args) => git(root, args, { allowFail: true }).split("\n").map((l) => l.trim()).filter(Boolean);
3501
+ function commitFiles(root, cwd, cmd) {
3502
+ const top = git(cwd, ["rev-parse", "--show-toplevel"], { allowFail: true }).trim();
3503
+ if (!top) return [];
3504
+ const list = (args) => git(cwd, [...args, "-z"], { allowFail: true }).split("\0").filter(Boolean);
3502
3505
  const files = new Set(list(["diff", "--cached", "--name-only"]));
3503
3506
  if (/\s(-[a-zA-Z]*a[a-zA-Z]*|--all)\b/.test(cmd))
3504
3507
  for (const f of list(["diff", "--name-only"])) files.add(f);
3505
- return [...files];
3508
+ return [...files].map((f) => relative2(root, join7(top, f)));
3506
3509
  }
3507
3510
  function commitKnowledge(ctx, input) {
3508
3511
  if (!ctx.config.recall.onCommit || input.tool_name !== "Bash") return void 0;
@@ -3510,7 +3513,7 @@ function commitKnowledge(ctx, input) {
3510
3513
  if (!/(^|[;&|]\s*)git\s+commit\b/.test(cmd)) return void 0;
3511
3514
  try {
3512
3515
  const db = getStorage(ctx, { vectors: false });
3513
- return commitContext(db, commitFiles(ctx.root, cmd)) || void 0;
3516
+ return commitContext(db, commitFiles(ctx.root, input.cwd || ctx.root, cmd)) || void 0;
3514
3517
  } catch {
3515
3518
  return void 0;
3516
3519
  }
@@ -3572,14 +3575,14 @@ ${extra}` : extra
3572
3575
  var preToolUse = async (input) => {
3573
3576
  if (!input.tool_name || !input.tool_input) return void 0;
3574
3577
  if (isSwarmTool(input.tool_name)) return swarmStampCaller(input);
3575
- const ctx = getContext(input.cwd);
3578
+ const ctx = sessionContext(input.cwd);
3576
3579
  if (input.agent_id) swarmTouch(ctx, input);
3577
3580
  const spawn = swarmPreAgent(ctx, input);
3578
3581
  if (spawn?.kind === "deny") return spawn.output;
3579
3582
  const out = await route(ctx, input, spawn?.kind === "worker");
3580
3583
  if (!ctx.config.adjudicator.enabled || input.client === "cursor") return out;
3581
3584
  try {
3582
- const { afterRouting } = await import("./hook-hooks-5U2AI6W7.js");
3585
+ const { afterRouting } = await import("./hook-hooks-5H6LFYD5.js");
3583
3586
  return await afterRouting(ctx, input, spawn, out);
3584
3587
  } catch {
3585
3588
  return out;
@@ -3764,7 +3767,7 @@ function routingGuidance(mode) {
3764
3767
  ].join("\n");
3765
3768
  }
3766
3769
  var sessionStart = async (input) => {
3767
- const ctx = getContext(input.cwd);
3770
+ const ctx = sessionContext(input.cwd);
3768
3771
  const sessionId = input.session_id || "unknown";
3769
3772
  setCurrentSession(ctx, sessionId);
3770
3773
  const db = getStorage(ctx, { vectors: false });
@@ -3819,7 +3822,7 @@ ${guide}`);
3819
3822
  if (swarm) parts.push(swarm);
3820
3823
  if (ctx.config.adjudicator.enabled && input.client !== "cursor") {
3821
3824
  try {
3822
- const { onSessionStart } = await import("./hook-hooks-5U2AI6W7.js");
3825
+ const { onSessionStart } = await import("./hook-hooks-5H6LFYD5.js");
3823
3826
  const line2 = onSessionStart(ctx, db, input);
3824
3827
  if (line2) parts.push(line2);
3825
3828
  } catch {
@@ -3956,7 +3959,7 @@ function failClosed(input, err) {
3956
3959
  if (input.hook_event_name !== "PreToolUse" || input.client === "cursor" || input.tool_name !== "Agent" && input.tool_name !== "Task" || !rawEnforced({ cwd: input.cwd }))
3957
3960
  return void 0;
3958
3961
  try {
3959
- swarmAgentReturned(getContext(input.cwd), input);
3962
+ swarmAgentReturned(sessionContext(input.cwd), input);
3960
3963
  } catch {
3961
3964
  }
3962
3965
  return JSON.stringify({
@@ -3988,7 +3991,7 @@ async function runCursor(parsed, budgetMs2) {
3988
3991
  }
3989
3992
  let root = input.cwd;
3990
3993
  try {
3991
- root = getContext(input.cwd).root;
3994
+ root = sessionContext(input.cwd).root;
3992
3995
  } catch {
3993
3996
  }
3994
3997
  try {
@@ -4012,7 +4015,7 @@ async function main() {
4012
4015
  return;
4013
4016
  }
4014
4017
  if (process.argv.includes("--adjudicate")) {
4015
- const { ASYNC_JOB_MAX_MS, runAsyncJob } = await import("./hook-async-3TLK23ZY.js");
4018
+ const { ASYNC_JOB_MAX_MS, runAsyncJob } = await import("./hook-async-7GK6H3OO.js");
4016
4019
  setTimeout(() => process.exit(0), ASYNC_JOB_MAX_MS).unref();
4017
4020
  await runAsyncJob(raw, { log: (line2) => hookLog("info", line2) });
4018
4021
  return;