@atlasharness/atlascode 0.1.67 → 0.1.68

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.
Files changed (2) hide show
  1. package/dist/cli.js +57 -15
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -80987,10 +80987,10 @@ function buildPostCompactMessages(result) {
80987
80987
  ...result.hookResults
80988
80988
  ];
80989
80989
  }
80990
- function compactConversation(messages, contextOrDeps, cacheSafeParamsOrInstructions, suppressFollowUpQuestions, customInstructions, isAutoCompact, recompactionInfo) {
80990
+ function compactConversation(messages, contextOrDeps, cacheSafeParamsOrInstructions, suppressFollowUpQuestions, customInstructions, isAutoCompact, recompactionInfo, keepRecent) {
80991
80991
  const rich = typeof contextOrDeps.getAppState === "function";
80992
80992
  if (rich) {
80993
- return richCompactConversation(messages, contextOrDeps, cacheSafeParamsOrInstructions, suppressFollowUpQuestions ?? false, customInstructions, isAutoCompact ?? false, recompactionInfo);
80993
+ return richCompactConversation(messages, contextOrDeps, cacheSafeParamsOrInstructions, suppressFollowUpQuestions ?? false, customInstructions, isAutoCompact ?? false, recompactionInfo, keepRecent ?? 0);
80994
80994
  }
80995
80995
  return trimmedCompactConversation(messages, contextOrDeps, typeof cacheSafeParamsOrInstructions === "string" ? cacheSafeParamsOrInstructions : undefined);
80996
80996
  }
@@ -81039,7 +81039,7 @@ async function trimmedCompactConversation(messages, deps, customInstructions) {
81039
81039
  }
81040
81040
  return result;
81041
81041
  }
81042
- async function richCompactConversation(messages, context, cacheSafeParams, suppressFollowUpQuestions, customInstructions, isAutoCompact, recompactionInfo) {
81042
+ async function richCompactConversation(messages, context, cacheSafeParams, suppressFollowUpQuestions, customInstructions, isAutoCompact, recompactionInfo, keepRecent = 0) {
81043
81043
  const p = getCompactPorts();
81044
81044
  if (!p) {
81045
81045
  throw new Error("compactConversation rich path requires setCompactPorts(...) — register host compact ports (tui wiring, D-2a S8)");
@@ -81140,6 +81140,7 @@ async function richCompactConversation(messages, context, cacheSafeParams, suppr
81140
81140
  preCompactDiscoveredTools: [...preCompactDiscovered].sort()
81141
81141
  };
81142
81142
  }
81143
+ const messagesToKeep = keepRecent > 0 ? messages.slice(-keepRecent) : undefined;
81143
81144
  const transcriptPath = getTranscriptPath();
81144
81145
  const summaryMessages = [
81145
81146
  {
@@ -81149,7 +81150,7 @@ async function richCompactConversation(messages, context, cacheSafeParams, suppr
81149
81150
  timestamp: new Date().toISOString(),
81150
81151
  message: {
81151
81152
  role: "user",
81152
- content: getCompactUserSummaryMessage(summary, suppressFollowUpQuestions, transcriptPath)
81153
+ content: getCompactUserSummaryMessage(summary, suppressFollowUpQuestions, transcriptPath, messagesToKeep !== undefined)
81153
81154
  }
81154
81155
  }
81155
81156
  ];
@@ -81159,6 +81160,7 @@ async function richCompactConversation(messages, context, cacheSafeParams, suppr
81159
81160
  const truePostCompactTokenCount = roughTokenCountEstimationForMessages([
81160
81161
  boundaryMarker,
81161
81162
  ...summaryMessages,
81163
+ ...messagesToKeep ?? [],
81162
81164
  ...postCompactFileAttachments,
81163
81165
  ...hookMessages
81164
81166
  ]);
@@ -81184,6 +81186,7 @@ async function richCompactConversation(messages, context, cacheSafeParams, suppr
81184
81186
  summaryMessages,
81185
81187
  attachments: postCompactFileAttachments,
81186
81188
  hookResults: hookMessages,
81189
+ ...messagesToKeep ? { messagesToKeep } : {},
81187
81190
  userDisplayMessage: combinedUserDisplayMessage || undefined,
81188
81191
  preCompactTokenCount,
81189
81192
  postCompactTokenCount: compactionCallTotalTokens,
@@ -81499,6 +81502,9 @@ function getAutoCompactThreshold(contextWindowOrModel, maxOutputTokens, pctOverr
81499
81502
  }
81500
81503
  return getAutoCompactThresholdCore(contextWindowOrModel, maxOutputTokens, pctOverride, windowOverride);
81501
81504
  }
81505
+ function isAutoCompactThresholdPositive(contextWindow, maxOutputTokens, pctOverride, windowOverride) {
81506
+ return getAutoCompactThreshold(contextWindow, maxOutputTokens, pctOverride, windowOverride) > 0;
81507
+ }
81502
81508
  function calculateTokenWarningState(tokenUsage, paramsOrModel) {
81503
81509
  if (typeof paramsOrModel === "string") {
81504
81510
  const env = getAutoCompactEnvOverrides();
@@ -81524,13 +81530,15 @@ function calculateTokenWarningStateCore(tokenUsage, params) {
81524
81530
  } = params;
81525
81531
  const enabled = autoCompactEnabled !== false;
81526
81532
  const autoCompactThreshold = getAutoCompactThreshold(contextWindow, maxOutputTokens, pctOverride, windowOverride);
81527
- const threshold = enabled ? autoCompactThreshold : getEffectiveContextWindowSize(contextWindow, maxOutputTokens, windowOverride);
81533
+ const thresholdUsable = isAutoCompactThresholdPositive(contextWindow, maxOutputTokens, pctOverride, windowOverride);
81534
+ const effectivelyEnabled = enabled && thresholdUsable;
81535
+ const threshold = effectivelyEnabled ? autoCompactThreshold : getEffectiveContextWindowSize(contextWindow, maxOutputTokens, windowOverride);
81528
81536
  const percentLeft = Math.max(0, Math.round((threshold - tokenUsage) / threshold * 100));
81529
81537
  const warningThreshold = threshold - WARNING_THRESHOLD_BUFFER_TOKENS;
81530
81538
  const errorThreshold = threshold - ERROR_THRESHOLD_BUFFER_TOKENS;
81531
81539
  const isAboveWarningThreshold = tokenUsage >= warningThreshold;
81532
81540
  const isAboveErrorThreshold = tokenUsage >= errorThreshold;
81533
- const isAboveAutoCompactThreshold = enabled && tokenUsage >= autoCompactThreshold;
81541
+ const isAboveAutoCompactThreshold = effectivelyEnabled && tokenUsage >= autoCompactThreshold;
81534
81542
  const actualContextWindow = getEffectiveContextWindowSize(contextWindow, maxOutputTokens, windowOverride);
81535
81543
  const defaultBlockingLimit = actualContextWindow - MANUAL_COMPACT_BUFFER_TOKENS;
81536
81544
  const blockingLimit = blockingLimitOverride !== undefined && blockingLimitOverride > 0 ? blockingLimitOverride : defaultBlockingLimit;
@@ -81540,7 +81548,8 @@ function calculateTokenWarningStateCore(tokenUsage, params) {
81540
81548
  isAboveWarningThreshold,
81541
81549
  isAboveErrorThreshold,
81542
81550
  isAboveAutoCompactThreshold,
81543
- isAtBlockingLimit
81551
+ isAtBlockingLimit,
81552
+ ...enabled && !thresholdUsable ? { autoCompactDisabledBySmallWindow: true } : {}
81544
81553
  };
81545
81554
  }
81546
81555
  function isAutoCompactEnabled(flags) {
@@ -81571,6 +81580,9 @@ async function shouldAutoCompact(messages, deps) {
81571
81580
  if (!deps.countTokens) {
81572
81581
  return false;
81573
81582
  }
81583
+ if (!isAutoCompactThresholdPositive(deps.contextWindow, deps.maxOutputTokens, deps.pctOverride, deps.windowOverride)) {
81584
+ return false;
81585
+ }
81574
81586
  const tokenCount = await deps.countTokens(messages);
81575
81587
  if (!Number.isFinite(tokenCount)) {
81576
81588
  return false;
@@ -81606,7 +81618,7 @@ async function autoCompactIfNeeded(messages, tracking, deps) {
81606
81618
  };
81607
81619
  }
81608
81620
  }
81609
- var AUTOCOMPACT_BUFFER_TOKENS = 13000, MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3, autoCompactSettingsSource = null, autoCompactWindowSettingsSource = null, WARNING_THRESHOLD_BUFFER_TOKENS = 20000, ERROR_THRESHOLD_BUFFER_TOKENS = 20000, MANUAL_COMPACT_BUFFER_TOKENS = 3000;
81621
+ var AUTOCOMPACT_BUFFER_TOKENS = 13000, MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3, autoCompactSettingsSource = null, autoCompactWindowSettingsSource = null, WARNING_THRESHOLD_BUFFER_TOKENS = 20000, ERROR_THRESHOLD_BUFFER_TOKENS = 20000, MANUAL_COMPACT_BUFFER_TOKENS = 3000, AUTOCOMPACT_KEEP_RECENT = 3;
81610
81622
  var init_autoCompact = __esm(() => {
81611
81623
  init_modelprovider2();
81612
81624
  init_config();
@@ -81614,6 +81626,23 @@ var init_autoCompact = __esm(() => {
81614
81626
  init_autoCompactWindow();
81615
81627
  });
81616
81628
 
81629
+ // src/engine/context/autoCompactRich.ts
81630
+ function createAutoCompactCompact(options) {
81631
+ return (messages) => {
81632
+ if (options.richContext && getCompactPorts()) {
81633
+ return compactConversation(messages, options.richContext, options.buildCacheSafeParams(messages), true, undefined, true, undefined, options.keepRecent ?? 0);
81634
+ }
81635
+ return compactConversation(messages, {
81636
+ summarize: options.trimmedSummarize,
81637
+ countTokens: options.countTokens,
81638
+ keepRecent: 0
81639
+ });
81640
+ };
81641
+ }
81642
+ var init_autoCompactRich = __esm(() => {
81643
+ init_compact();
81644
+ });
81645
+
81617
81646
  // src/engine/context/compactWarningState.ts
81618
81647
  function suppressCompactWarning() {
81619
81648
  compactWarningStore.setState(() => true);
@@ -82088,6 +82117,7 @@ var init_context = __esm(() => {
82088
82117
  init_autoCompact();
82089
82118
  init_autoCompactWindow();
82090
82119
  init_autoCompact();
82120
+ init_autoCompactRich();
82091
82121
  init_compact();
82092
82122
  init_compactPtl();
82093
82123
  init_microCompact();
@@ -82241,7 +82271,7 @@ async function queryAgentLoop(deps, args) {
82241
82271
  turns++;
82242
82272
  if (args.context?.autoCompact) {
82243
82273
  const oc = await autoCompactIfNeeded(messages, tracking, args.context.autoCompact);
82244
- if (oc.wasCompacted && oc.compactionResult) {
82274
+ if (oc.wasCompacted && oc.compactionResult && !oc.compactionResult.compactionSkipped) {
82245
82275
  messages = buildPostCompactMessages(oc.compactionResult);
82246
82276
  if (oc.tracking) {
82247
82277
  tracking = oc.tracking;
@@ -82265,7 +82295,7 @@ async function queryAgentLoop(deps, args) {
82265
82295
  tracking = { ...tracking, consecutiveFailures: oc.consecutiveFailures };
82266
82296
  reportAutoCompactCircuitFailures(oc.consecutiveFailures);
82267
82297
  }
82268
- if (oc.wasCompacted && oc.compactionResult) {
82298
+ if (oc.wasCompacted && oc.compactionResult && !oc.compactionResult.compactionSkipped) {
82269
82299
  deps.emit?.({ type: "compacted", turn: turns, messages });
82270
82300
  }
82271
82301
  }
@@ -180228,6 +180258,7 @@ __export(exports_engineCompat, {
180228
180258
  ASK_USER_QUESTION_TOOL_NAME: () => ASK_USER_QUESTION_TOOL_NAME,
180229
180259
  ASYNC_AGENT_ALLOWED_TOOLS: () => ASYNC_AGENT_ALLOWED_TOOLS,
180230
180260
  AUTOCOMPACT_BUFFER_TOKENS: () => AUTOCOMPACT_BUFFER_TOKENS,
180261
+ AUTOCOMPACT_KEEP_RECENT: () => AUTOCOMPACT_KEEP_RECENT,
180231
180262
  AUTOCOMPACT_PRESET_WINDOW_TIERS: () => AUTOCOMPACT_PRESET_WINDOW_TIERS,
180232
180263
  AbortError: () => AbortError,
180233
180264
  AgentTool: () => AgentTool,
@@ -180432,6 +180463,7 @@ __export(exports_engineCompat, {
180432
180463
  createActivityDescriptionResolver: () => createActivityDescriptionResolver,
180433
180464
  createAgentLoopDeps: () => createAgentLoopDeps,
180434
180465
  createAgentWorktree: () => createAgentWorktree,
180466
+ createAutoCompactCompact: () => createAutoCompactCompact,
180435
180467
  createChildAbortController: () => createChildAbortController,
180436
180468
  createCompactBoundaryMessage: () => createCompactBoundaryMessage,
180437
180469
  createCronScheduler: () => createCronScheduler,
@@ -180647,6 +180679,7 @@ __export(exports_engineCompat, {
180647
180679
  isAscendToolsEnabled: () => isAscendToolsEnabled,
180648
180680
  isAutoCompactCircuitTripped: () => isAutoCompactCircuitTripped,
180649
180681
  isAutoCompactEnabled: () => isAutoCompactEnabled,
180682
+ isAutoCompactThresholdPositive: () => isAutoCompactThresholdPositive,
180650
180683
  isAutoModeGateEnabled: () => isAutoModeGateEnabled,
180651
180684
  isBuiltInAgent: () => isBuiltInAgent,
180652
180685
  isBypassPermissionsModeDisabled: () => isBypassPermissionsModeDisabled,
@@ -321265,8 +321298,8 @@ function buildAgentLoopParams(m) {
321265
321298
  enabled: mergedAutoCompact.autoCompactDisabled ? false : undefined,
321266
321299
  pctOverride: mergedAutoCompact.pctOverride,
321267
321300
  windowOverride: mergedAutoCompact.windowOverride,
321268
- compact: (msgs) => compactConversation(msgs, {
321269
- summarize: async (compactMsgs, prompt) => {
321301
+ compact: createAutoCompactCompact({
321302
+ trimmedSummarize: async (compactMsgs, prompt) => {
321270
321303
  const resp = await modelProvider.chat({
321271
321304
  messages: [...compactMsgs, prompt],
321272
321305
  role,
@@ -321278,7 +321311,15 @@ function buildAgentLoopParams(m) {
321278
321311
  return blocks.filter((b) => typeof b === "object" && b !== null && b.type === "text").map((b) => b.text ?? "").join("");
321279
321312
  },
321280
321313
  countTokens,
321281
- keepRecent: 0
321314
+ richContext: m.toolUseContext,
321315
+ keepRecent: AUTOCOMPACT_KEEP_RECENT,
321316
+ buildCacheSafeParams: (msgs) => ({
321317
+ systemPrompt: m.systemPrompt,
321318
+ userContext: m.userContext,
321319
+ systemContext: m.systemContext,
321320
+ toolUseContext: m.toolUseContext,
321321
+ forkContextMessages: msgs
321322
+ })
321282
321323
  }),
321283
321324
  querySource: m.querySource
321284
321325
  };
@@ -451336,7 +451377,8 @@ function TokenWarning(t0) {
451336
451377
  const {
451337
451378
  percentLeft,
451338
451379
  isAboveWarningThreshold,
451339
- isAboveErrorThreshold
451380
+ isAboveErrorThreshold,
451381
+ autoCompactDisabledBySmallWindow
451340
451382
  } = t1;
451341
451383
  const suppressWarning = useCompactWarningSuppression();
451342
451384
  const circuitFailures = useAutoCompactCircuitFailures();
@@ -451402,7 +451444,7 @@ function TokenWarning(t0) {
451402
451444
  return t4;
451403
451445
  }
451404
451446
  const circuitTripped = isAutoCompactCircuitTripped(circuitFailures);
451405
- const autocompactLabel = circuitTripped ? `auto-compact paused after ${circuitFailures} consecutive failures · run /compact, switch to a smaller model, or start a new session` : reactiveOnlyMode ? `${100 - displayPercentLeft}% context used` : `${displayPercentLeft}% until auto-compact`;
451447
+ const autocompactLabel = circuitTripped ? `auto-compact paused after ${circuitFailures} consecutive failures · run /compact, switch to a smaller model, or start a new session` : reactiveOnlyMode ? `${100 - displayPercentLeft}% context used` : autoCompactDisabledBySmallWindow ? `context window too small for auto-compact · auto-compact disabled · run /compact manually or use a smaller-context model` : `${displayPercentLeft}% until auto-compact`;
451406
451448
  let t4;
451407
451449
  if ($[9] !== autocompactLabel || $[10] !== isAboveErrorThreshold || $[11] !== percentLeft) {
451408
451450
  t4 = /* @__PURE__ */ jsx_dev_runtime364.jsxDEV(ThemedBox_default, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlasharness/atlascode",
3
- "version": "0.1.67",
3
+ "version": "0.1.68",
4
4
  "description": "AtlasCode \u2014 Coding Agent for the domestic computing ecosystem (Ascend NPU + domestic LLM backends)",
5
5
  "bin": {
6
6
  "atlas": "dist/cli.js",