Lines 1-25javascript
1// _helpers.ts — shared utilities for NexusMind Codex CLI hook handlers.
2// Every hook is a short-lived Node process invoked by Codex with a JSON payload
3// on stdin. These helpers keep that contract consistent: parse stdin, resolve
4// env config, detect the project, hit the backend with a hard timeout, and
5// format/emit output the way Codex expects.
6import { spawnSync } from 'node:child_process';
7import { basename } from 'node:path';
HighChild Process
Package source references child process execution.
dist/hooks/_helpers.jsView on unpkg · L5 8export const DEFAULT_BASE_URL = 'https://nexusmind-backend.fly.dev';
9export const HEALTH_TIMEOUT_MS = 5000;
10export const FETCH_TIMEOUT_MS = 8000;
11export const STORE_TIMEOUT_MS = 10000;
12function envInt(name, fallback) {
13 const raw = process.env[name];
14 if (!raw)
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
dist/hooks/_helpers.jsView on unpkg · L5 16 const n = parseInt(raw, 10);
17 return Number.isFinite(n) && n > 0 ? n : fallback;
19export const SESSION_PROJECT_LIMIT = envInt('NEXUSMIND_SESSION_PROJECT_LIMIT', 8);
20export const SESSION_RECENT_LIMIT = envInt('NEXUSMIND_SESSION_RECENT_LIMIT', 5);
21export const PROMPT_MEMORY_LIMIT = envInt('NEXUSMIND_PROMPT_MEMORY_LIMIT', 3);
22export const PROMPT_INJECT_MODE = (process.env.NEXUSMIND_PROMPT_INJECT ?? 'minimal').toLowerCase();
23export const RECALL_KEYWORDS = /remember|recall|recuerda|acordate|what did we|qué hicimos/i;
24export const DECISION_KEYWORDS = /decided|decision|fixed|error|warning|convention|architecture|discovered|discovery|issue|solution|implemented|changed|added|removed|refactored|pattern|config|gotcha|caveat|note|important/