@alaarab/cortex 1.15.3 → 1.15.4

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.
@@ -607,7 +607,7 @@ export function getListItems(cortexPath, profile, state, healthLineCount) {
607
607
  return getProjectSkills(cortexPath, state.project).map((s) => ({ name: s.name, text: s.path }));
608
608
  }
609
609
  case "Hooks": {
610
- return getHookEntries(cortexPath).map((e) => ({ name: e.tool, text: e.enabled ? "enabled" : "disabled" }));
610
+ return getHookEntries(cortexPath).map((e) => ({ name: e.event, text: e.enabled ? "active" : "inactive" }));
611
611
  }
612
612
  case "Health":
613
613
  return Array.from({ length: Math.max(1, healthLineCount) }, (_, i) => ({ id: String(i) }));
@@ -663,7 +663,7 @@ export async function activateSelected(host) {
663
663
  break;
664
664
  case "Hooks":
665
665
  if (item.name) {
666
- host.setMessage(` ${item.text === "enabled" ? style.boldGreen("enabled") : style.dim("disabled")} ${style.bold(item.name)}`);
666
+ host.setMessage(` ${item.text === "active" ? style.boldGreen("active") : style.dim("inactive")} ${style.bold(item.name)}`);
667
667
  }
668
668
  break;
669
669
  }
@@ -766,11 +766,10 @@ export async function doViewAction(host, key) {
766
766
  }
767
767
  break;
768
768
  case "Hooks":
769
- if ((key === "a" || key === "d") && item?.name) {
769
+ if (key === "a" || key === "d") {
770
770
  const enable = key === "a";
771
- const prefs = { hookTools: { ...((getHookEntries(host.cortexPath).reduce((acc, e) => ({ ...acc, [e.tool]: e.enabled }), {}))), [item.name]: enable } };
772
- writeInstallPreferences(host.cortexPath, prefs);
773
- host.setMessage(` ${enable ? style.boldGreen("Enabled") : style.dim("Disabled")} hooks for ${item.name}`);
771
+ writeInstallPreferences(host.cortexPath, { hooksEnabled: enable });
772
+ host.setMessage(` Hooks ${enable ? style.boldGreen("enabled") : style.dim("disabled")} — takes effect next session`);
774
773
  }
775
774
  break;
776
775
  }
@@ -434,20 +434,20 @@ export function renderSkillsView(ctx, cursor, height) {
434
434
  }
435
435
  return vp.lines;
436
436
  }
437
- // ── Hooks view ─────────────────────────────────────────────────────────────
438
- const HOOK_TOOLS = ["claude", "copilot", "cursor", "codex"];
437
+ const LIFECYCLE_HOOKS = [
438
+ { event: "UserPromptSubmit", description: "inject context before each prompt" },
439
+ { event: "Stop", description: "auto-save findings after each response" },
440
+ { event: "SessionStart", description: "git pull at session start" },
441
+ ];
439
442
  export function getHookEntries(cortexPath) {
440
443
  const prefs = readInstallPreferences(cortexPath);
441
444
  const hooksEnabled = prefs.hooksEnabled !== false;
442
- const toolPrefs = (prefs.hookTools && typeof prefs.hookTools === "object") ? prefs.hookTools : {};
443
- return HOOK_TOOLS.map((tool) => ({
444
- tool,
445
- enabled: hooksEnabled && toolPrefs[tool] !== false,
446
- }));
445
+ return LIFECYCLE_HOOKS.map((h) => ({ ...h, enabled: hooksEnabled }));
447
446
  }
448
447
  export function renderHooksView(ctx, cursor, height) {
449
448
  const cols = process.stdout.columns || 80;
450
449
  const entries = getHookEntries(ctx.cortexPath);
450
+ const allEnabled = entries.every((e) => e.enabled);
451
451
  const allLines = [];
452
452
  let cursorFirstLine = 0;
453
453
  let cursorLastLine = 0;
@@ -456,16 +456,24 @@ export function renderHooksView(ctx, cursor, height) {
456
456
  const isSelected = i === cursor;
457
457
  if (isSelected)
458
458
  cursorFirstLine = allLines.length;
459
- const statusBadge = e.enabled ? style.boldGreen("enabled ") : style.dim("disabled");
460
- let row = ` ${style.dim((i + 1).toString().padEnd(3))} ${statusBadge} ${style.bold(e.tool)}`;
461
- if (isSelected)
462
- row = `\x1b[7m${padToWidth(row, cols)}${RESET}`;
463
- else
464
- row = truncateLine(row, cols);
465
- allLines.push(row);
459
+ const statusBadge = e.enabled ? style.boldGreen("active ") : style.dim("inactive");
460
+ let nameRow = ` ${style.dim((i + 1).toString().padEnd(3))} ${statusBadge} ${style.bold(e.event)}`;
461
+ let descRow = ` ${style.dim(e.description)}`;
462
+ if (isSelected) {
463
+ nameRow = `\x1b[7m${padToWidth(nameRow, cols)}${RESET}`;
464
+ descRow = `\x1b[7m${padToWidth(descRow, cols)}${RESET}`;
465
+ }
466
+ else {
467
+ nameRow = truncateLine(nameRow, cols);
468
+ descRow = truncateLine(descRow, cols);
469
+ }
470
+ allLines.push(nameRow);
471
+ allLines.push(descRow);
466
472
  if (isSelected)
467
473
  cursorLastLine = allLines.length - 1;
468
474
  }
475
+ allLines.push("");
476
+ allLines.push(style.dim(` hooks: ${allEnabled ? style.boldGreen("ON") : style.boldRed("OFF")} · ${style.dim("a = enable all · d = disable all")}`));
469
477
  const usableHeight = Math.max(1, height - (allLines.length > height ? 1 : 0));
470
478
  const vp = lineViewport(allLines, cursorFirstLine, cursorLastLine, usableHeight, ctx.currentScroll());
471
479
  ctx.setScroll(vp.scrollStart);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alaarab/cortex",
3
- "version": "1.15.3",
3
+ "version": "1.15.4",
4
4
  "description": "Long-term memory for AI agents. Stored as markdown in a git repo you own.",
5
5
  "type": "module",
6
6
  "bin": {