@iaforged/context-code 2.1.5 → 2.1.6

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.
@@ -1 +1 @@
1
- import e from"chalk";import{writeSync as t}from"fs";import r from"lodash-es/memoize.js";import{onExit as o}from"signal-exit";import{getIsInteractive as s,getIsScrollDraining as n,getLastMainRequestId as i,getSessionId as c,isSessionPersistenceDisabled as a}from"../bootstrap/state.js";import u from"../ink/instances.js";import{DISABLE_KITTY_KEYBOARD as m,DISABLE_MODIFY_OTHER_KEYS as l}from"../ink/termio/csi.js";import{DBP as p,DFE as d,DISABLE_MOUSE_TRACKING as f,EXIT_ALT_SCREEN as g,SHOW_CURSOR as h}from"../ink/termio/dec.js";import{CLEAR_ITERM2_PROGRESS as _,CLEAR_TAB_STATUS as T,CLEAR_TERMINAL_TITLE as w,supportsTabStatus as E,wrapForMultiplexer as S}from"../ink/termio/osc.js";import{shutdownDatadog as x}from"../services/analytics/datadog.js";import{shutdown1PEventLogging as v}from"../services/analytics/firstPartyEventLogger.js";import{logEvent as j}from"../services/analytics/index.js";import{runCleanupFunctions as y}from"./cleanupRegistry.js";import{logForDebugging as I}from"./debug.js";import{logForDiagnosticsNoPII as M}from"./diagLogs.js";import{isEnvTruthy as k}from"./envUtils.js";import{getCurrentSessionTitle as L,sessionIdExists as R}from"./sessionStorage.js";import{sleep as C}from"./sleep.js";import{profileReport as G}from"./startupProfiler.js";function cleanupTerminalModes(){if(process.stdout.isTTY)try{t(1,f);const e=u.get(process.stdout);if(e?.isAltScreenActive)try{e.unmount()}catch{t(1,g)}e?.drainStdin(),e?.detachForShutdown(),t(1,l),t(1,m),t(1,d),t(1,p),t(1,h),t(1,_),E()&&t(1,S(T)),k(process.env.CONTEXT_CODE_DISABLE_TERMINAL_TITLE)||k(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE)||("win32"===process.platform?process.title="":t(1,w))}catch{}}let N=!1;function printResumeHint(){if(!N&&process.stdout.isTTY&&s()&&!a())try{const r=c();if(!R(r))return;const o=L(r);let s;if(o){s=`"${o.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}else s=r;t(1,e.dim(`\nReanuda esta sesión con:\ncontext --resume ${s}\n`)),N=!0}catch{}}function forceExit(e){void 0!==P&&(clearTimeout(P),P=void 0);try{u.get(process.stdout)?.drainStdin()}catch{}try{process.exit(e)}catch(e){if("test"===process.env.NODE_ENV)throw e;process.kill(process.pid,"SIGKILL")}if("test"!==process.env.NODE_ENV)throw new Error("unreachable")}export const setupGracefulShutdown=r(()=>{o(()=>{}),process.on("SIGINT",()=>{process.argv.includes("-p")||process.argv.includes("--print")||(H&&(cleanupTerminalModes(),forceExit(130)),M("info","shutdown_signal",{signal:"SIGINT"}),gracefulShutdown(0))}),process.on("SIGTERM",()=>{M("info","shutdown_signal",{signal:"SIGTERM"}),gracefulShutdown(143)}),"win32"!==process.platform&&(process.on("SIGHUP",()=>{M("info","shutdown_signal",{signal:"SIGHUP"}),gracefulShutdown(129)}),process.stdin.isTTY&&(A=setInterval(()=>{n()||process.stdout.writable&&process.stdin.readable||(clearInterval(A),M("info","shutdown_signal",{signal:"orphan_detected"}),gracefulShutdown(129))},3e4),A.unref())),process.on("uncaughtException",e=>{M("error","uncaught_exception",{error_name:e.name,error_message:e.message.slice(0,2e3)}),j("tengu_uncaught_exception",{error_name:e.name})}),process.on("unhandledRejection",e=>{const t=e instanceof Error?e.name:"string"==typeof e?"string":"unknown",r=e instanceof Error?{error_name:e.name,error_message:e.message.slice(0,2e3),error_stack:e.stack?.slice(0,4e3)}:{error_message:String(e).slice(0,2e3)};M("error","unhandled_rejection",r),j("tengu_unhandled_rejection",{error_name:t})})});export function gracefulShutdownSync(e=0,t="other",r){process.exitCode=e,D=gracefulShutdown(e,t,r).catch(t=>{I(`Graceful shutdown failed: ${t}`,{level:"error"}),cleanupTerminalModes(),printResumeHint(),forceExit(e)}).catch(()=>{})}let P,A,D,H=!1;export function isShuttingDown(){return H}export function resetShutdownState(){H=!1,N=!1,void 0!==P&&(clearTimeout(P),P=void 0),D=void 0}export function getPendingShutdownForTesting(){return D}export async function gracefulShutdown(e=0,r="other",o){if(H)return;H=!0;const{executeSessionEndHooks:s,getSessionEndHookTimeoutMs:n}=await import("./hooks.js"),c=n();let a;P=setTimeout(e=>{cleanupTerminalModes(),printResumeHint(),forceExit(e)},Math.max(5e3,c+3500),e),P.unref(),process.exitCode=e,cleanupTerminalModes(),printResumeHint();try{const e=(async()=>{try{await y()}catch{}})();await Promise.race([e,new Promise((e,t)=>{a=setTimeout(e=>e(new CleanupTimeoutError),2e3,t)})]),clearTimeout(a)}catch{clearTimeout(a)}try{await s(r,{...o,signal:AbortSignal.timeout(c),timeoutMs:c})}catch{}try{G()}catch{}const u=i();u&&j("tengu_cache_eviction_hint",{scope:"session_end",last_request_id:u});try{await Promise.race([Promise.all([v(),x()]),C(500)])}catch{}if(o?.finalMessage)try{t(2,o.finalMessage+"\n")}catch{}forceExit(e)}class CleanupTimeoutError extends Error{constructor(){super("Cleanup timeout")}}
1
+ import e from"chalk";import{writeSync as t}from"fs";import r from"lodash-es/memoize.js";import{onExit as o}from"signal-exit";import{getIsInteractive as s,getIsScrollDraining as n,getLastMainRequestId as i,getSessionId as c,isSessionPersistenceDisabled as a}from"../bootstrap/state.js";import u from"../ink/instances.js";import{DISABLE_KITTY_KEYBOARD as m,DISABLE_MODIFY_OTHER_KEYS as l}from"../ink/termio/csi.js";import{DBP as p,DFE as d,DISABLE_MOUSE_TRACKING as f,EXIT_ALT_SCREEN as g,SHOW_CURSOR as h}from"../ink/termio/dec.js";import{CLEAR_ITERM2_PROGRESS as _,CLEAR_TAB_STATUS as T,CLEAR_TERMINAL_TITLE as w,supportsTabStatus as E,wrapForMultiplexer as S}from"../ink/termio/osc.js";import{shutdownDatadog as x}from"../services/analytics/datadog.js";import{shutdown1PEventLogging as v}from"../services/analytics/firstPartyEventLogger.js";import{logEvent as j}from"../services/analytics/index.js";import{runCleanupFunctions as y}from"./cleanupRegistry.js";import{logForDebugging as I}from"./debug.js";import{logForDiagnosticsNoPII as M}from"./diagLogs.js";import{isEnvTruthy as k}from"./envUtils.js";import{getCurrentSessionTitle as L,sessionIdExists as R}from"./sessionStorage.js";import{sleep as C}from"./sleep.js";import{profileReport as G}from"./startupProfiler.js";function cleanupTerminalModes(){if(process.stdout.isTTY)try{t(1,f);const e=u.get(process.stdout);if(e?.isAltScreenActive)try{e.unmount()}catch{t(1,g)}e?.drainStdin(),e?.detachForShutdown(),t(1,l),t(1,m),t(1,d),t(1,p),t(1,h),t(1,_),E()&&t(1,S(T)),k(process.env.CONTEXT_CODE_DISABLE_TERMINAL_TITLE)||k(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE)||("win32"===process.platform?process.title="":t(1,w))}catch{}}let N=!1;function printResumeHint(){if(!N&&process.stdout.isTTY&&s()&&!a())try{const r=c();if(!R(r))return;const o=L(r);let s;if(o){s=`"${o.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}else s=r;t(1,e.dim(`\nReanuda esta sesion con:\ncontext --resume ${s}\n`)),N=!0}catch{}}function forceExit(e){void 0!==P&&(clearTimeout(P),P=void 0);try{u.get(process.stdout)?.drainStdin()}catch{}try{process.exit(e)}catch(e){if("test"===process.env.NODE_ENV)throw e;process.kill(process.pid,"SIGKILL")}if("test"!==process.env.NODE_ENV)throw new Error("unreachable")}export const setupGracefulShutdown=r(()=>{o(()=>{}),process.on("SIGINT",()=>{process.argv.includes("-p")||process.argv.includes("--print")||(H&&(cleanupTerminalModes(),forceExit(130)),M("info","shutdown_signal",{signal:"SIGINT"}),gracefulShutdown(0))}),process.on("SIGTERM",()=>{M("info","shutdown_signal",{signal:"SIGTERM"}),gracefulShutdown(143)}),"win32"!==process.platform&&(process.on("SIGHUP",()=>{M("info","shutdown_signal",{signal:"SIGHUP"}),gracefulShutdown(129)}),process.stdin.isTTY&&(A=setInterval(()=>{n()||process.stdout.writable&&process.stdin.readable||(clearInterval(A),M("info","shutdown_signal",{signal:"orphan_detected"}),gracefulShutdown(129))},3e4),A.unref())),process.on("uncaughtException",e=>{M("error","uncaught_exception",{error_name:e.name,error_message:e.message.slice(0,2e3)}),j("tengu_uncaught_exception",{error_name:e.name})}),process.on("unhandledRejection",e=>{const t=e instanceof Error?e.name:"string"==typeof e?"string":"unknown",r=e instanceof Error?{error_name:e.name,error_message:e.message.slice(0,2e3),error_stack:e.stack?.slice(0,4e3)}:{error_message:String(e).slice(0,2e3)};M("error","unhandled_rejection",r),j("tengu_unhandled_rejection",{error_name:t})})});export function gracefulShutdownSync(e=0,t="other",r){process.exitCode=e,D=gracefulShutdown(e,t,r).catch(t=>{I(`Graceful shutdown failed: ${t}`,{level:"error"}),cleanupTerminalModes(),printResumeHint(),forceExit(e)}).catch(()=>{})}let P,A,D,H=!1;export function isShuttingDown(){return H}export function resetShutdownState(){H=!1,N=!1,void 0!==P&&(clearTimeout(P),P=void 0),D=void 0}export function getPendingShutdownForTesting(){return D}export async function gracefulShutdown(e=0,r="other",o){if(H)return;H=!0;const{executeSessionEndHooks:s,getSessionEndHookTimeoutMs:n}=await import("./hooks.js"),c=n();let a;P=setTimeout(e=>{cleanupTerminalModes(),printResumeHint(),forceExit(e)},Math.max(5e3,c+3500),e),P.unref(),process.exitCode=e,cleanupTerminalModes(),printResumeHint();try{const e=(async()=>{try{await y()}catch{}})();await Promise.race([e,new Promise((e,t)=>{a=setTimeout(e=>e(new CleanupTimeoutError),2e3,t)})]),clearTimeout(a)}catch{clearTimeout(a)}try{await s(r,{...o,signal:AbortSignal.timeout(c),timeoutMs:c})}catch{}try{G()}catch{}const u=i();u&&j("tengu_cache_eviction_hint",{scope:"session_end",last_request_id:u});try{await Promise.race([Promise.all([v(),x()]),C(500)])}catch{}if(o?.finalMessage)try{t(2,o.finalMessage+"\n")}catch{}forceExit(e)}class CleanupTimeoutError extends Error{constructor(){super("Cleanup timeout")}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iaforged/context-code",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "description": "Context Code es un asistente de desarrollo para la terminal. Puede revisar tu proyecto, editar archivos, ejecutar comandos y apoyarte en tareas reales de programacion.",
5
5
  "author": "Context AI",
6
6
  "license": "MIT",