blun-king-cli 9.1.279 → 9.1.280

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.
@@ -6,6 +6,8 @@ const path = require('node:path');
6
6
 
7
7
  const CANDIDATE_TTL_MS = 24 * 60 * 60 * 1000;
8
8
  const SCHEMA_VERSION = 1;
9
+ const TERMINAL_CANDIDATE_MAX = 200;
10
+ const TERMINAL_CANDIDATE_TRIM_TO = 100;
9
11
 
10
12
  const COMMAND_TOOLS = new Set([
11
13
  'bash',
@@ -171,6 +173,35 @@ function readValidatedLearningCandidates(options = {}) {
171
173
  }
172
174
  }
173
175
 
176
+ function pruneTerminalValidatedLearningCandidates(options = {}) {
177
+ const candidates = Array.isArray(options.candidates)
178
+ ? options.candidates
179
+ : readValidatedLearningCandidates(options);
180
+ const terminal = candidates.filter((candidate) => (
181
+ candidate.status === 'recorded' || candidate.status === 'expired'
182
+ ));
183
+ if (terminal.length <= TERMINAL_CANDIDATE_MAX) return { deleted: 0, failed: 0 };
184
+
185
+ const victims = terminal.slice(0, terminal.length - TERMINAL_CANDIDATE_TRIM_TO);
186
+ let deleted = 0;
187
+ let failed = 0;
188
+ for (const candidate of victims) {
189
+ if (typeof candidate.filePath !== 'string' || candidate.filePath.length === 0) {
190
+ failed += 1;
191
+ continue;
192
+ }
193
+ try {
194
+ fs.rmSync(candidate.filePath, { force: true });
195
+ fs.rmSync(statusMarker(candidate.filePath, 'recorded'), { force: true });
196
+ fs.rmSync(statusMarker(candidate.filePath, 'expired'), { force: true });
197
+ deleted += 1;
198
+ } catch {
199
+ failed += 1;
200
+ }
201
+ }
202
+ return { deleted, failed };
203
+ }
204
+
174
205
  function successfulMistakeRecordCandidateIds(history) {
175
206
  const calls = new Map();
176
207
  const candidateIds = new Set();
@@ -291,6 +322,10 @@ function syncValidatedLearningCandidate(history, options = {}) {
291
322
  if (expiredCandidate) {
292
323
  candidates = readValidatedLearningCandidates({ homeDir, profile: options.profile });
293
324
  }
325
+ const retention = pruneTerminalValidatedLearningCandidates({ candidates });
326
+ if (retention.deleted > 0) {
327
+ candidates = readValidatedLearningCandidates({ homeDir, profile: options.profile });
328
+ }
294
329
  if (signal !== null) {
295
330
  const duplicate = pendingCandidateForSignal(candidates, signal);
296
331
  if (duplicate !== null) {
@@ -315,6 +350,7 @@ function syncValidatedLearningCandidate(history, options = {}) {
315
350
  module.exports = {
316
351
  detectValidatedLearningSignal,
317
352
  normalizeCommand,
353
+ pruneTerminalValidatedLearningCandidates,
318
354
  readValidatedLearningCandidates,
319
355
  syncValidatedLearningCandidate,
320
356
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.279",
3
+ "version": "9.1.280",
4
4
  "description": "BLUN CLI - your own AI agent with a Telegram channel. Get it done. With BLUN.",
5
5
  "license": "MIT",
6
6
  "bin": {