@inetafrica/open-claudia 2.6.22 → 2.6.23

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.
@@ -291,6 +291,19 @@ const packsInjectedFor = new Map(); // `${adapterId}:${channelId}:${dir}` -> `${
291
291
  const PACK_INJECT_MAX_CHARS = 4000;
292
292
  const DEFAULT_MEMORY_RECALL_MAX_CHARS = 9000;
293
293
 
294
+ // Progressive disclosure: when on, a matched pack is injected as a cheap
295
+ // teaser (Stance + State + a pointer) rather than its full body. Heavy
296
+ // reference sections (Procedure, Journal) are fetched on demand via
297
+ // `open-claudia pack show`. Because each teaser is small we can widen the
298
+ // match count — surface more relevant packs for the same budget and let the
299
+ // agent decide which to read further.
300
+ function packProgressive() {
301
+ return String(config.PACK_PROGRESSIVE ?? process.env.PACK_PROGRESSIVE ?? "on").toLowerCase() === "on";
302
+ }
303
+ function packMatchLimit() {
304
+ return intSetting("PACK_MATCH_LIMIT", packProgressive() ? 6 : 3);
305
+ }
306
+
294
307
  function intSetting(key, fallback) {
295
308
  const raw = config[key] ?? process.env[key];
296
309
  if (raw === undefined || raw === null || raw === "") return fallback;
@@ -332,7 +345,8 @@ function consumeLastInjected() {
332
345
  return out;
333
346
  }
334
347
 
335
- function formatPackForContext(pack, packsLib) {
348
+ function formatPackForContext(pack, packsLib, opts = {}) {
349
+ const progressive = !!opts.progressive;
336
350
  const clip = (s, n) => (s.length > n ? s.slice(0, n) + "\n…[truncated — read the full pack file]" : s);
337
351
  const parts = [`### Pack: ${pack.name} (${pack.dir})`];
338
352
  if (pack.description) parts.push(pack.description);
@@ -345,12 +359,21 @@ function formatPackForContext(pack, packsLib) {
345
359
  const childLines = children.map((c) => `- ${c.dir}: ${c.description || c.name}`).join("\n");
346
360
  parts.push(`Sub-packs (dig deeper with \`open-claudia pack show <dir>\`):\n${childLines}`);
347
361
  }
348
- for (const section of ["Stance", "Procedure", "State"]) {
362
+ // Progressive mode injects only the live sections (Stance = how to think,
363
+ // State = where we are) plus a pointer; full mode also inlines Procedure
364
+ // and the recent Journal.
365
+ const sections = progressive ? ["Stance", "State"] : ["Stance", "Procedure", "State"];
366
+ for (const section of sections) {
349
367
  const body = (pack.sections[section] || "").trim();
350
368
  if (body) parts.push(`#### ${section}\n${body}`);
351
369
  }
352
- const journal = (pack.sections.Journal || "").trim().split("\n").filter(Boolean).slice(-10).join("\n");
353
- if (journal) parts.push(`#### Journal (recent)\n${journal}`);
370
+ if (progressive) {
371
+ const hasMore = (pack.sections.Procedure || "").trim() || (pack.sections.Journal || "").trim();
372
+ if (hasMore) parts.push(`#### More\nProcedure + Journal not shown — run \`open-claudia pack show ${pack.dir}\` to read them.`);
373
+ } else {
374
+ const journal = (pack.sections.Journal || "").trim().split("\n").filter(Boolean).slice(-10).join("\n");
375
+ if (journal) parts.push(`#### Journal (recent)\n${journal}`);
376
+ }
354
377
  return clip(parts.join("\n\n"), PACK_INJECT_MAX_CHARS);
355
378
  }
356
379
 
@@ -362,6 +385,7 @@ function buildPackBlock(matches, budget) {
362
385
  const adapter = currentAdapter();
363
386
  const channelId = currentChannelId();
364
387
  const sess = state.lastSessionId || "new";
388
+ const progressive = packProgressive();
365
389
  const blocks = [];
366
390
  const used = [];
367
391
  for (const m of matches) {
@@ -370,13 +394,13 @@ function buildPackBlock(matches, budget) {
370
394
  used.push(m.dir);
371
395
  const key = `${adapter?.id || "?"}:${channelId || "?"}:${m.dir}`;
372
396
  const stamp = `${sess}:${pack.updated}`;
373
- // Inject a pack's full body once per (channel, session, version). A
397
+ // Inject a pack's body once per (channel, session, version). A
374
398
  // compaction mints a new session id, which changes the stamp and
375
- // forces a fresh full re-injection on the next turn (same mechanism
399
+ // forces a fresh re-injection on the next turn (same mechanism
376
400
  // as the task tree), so the pack survives compaction without paying
377
401
  // to re-stamp an anchor on every intervening turn.
378
402
  if (packsInjectedFor.get(key) === stamp) continue;
379
- const block = formatPackForContext(pack, packsLib);
403
+ const block = formatPackForContext(pack, packsLib, { progressive });
380
404
  if (!tryUseRecallBudget(budget, block)) continue;
381
405
  packsInjectedFor.set(key, stamp);
382
406
  lastInjected.packs.push(pack.name || m.dir);
@@ -536,10 +560,11 @@ async function promptWithDynamicContext(prompt, opts = {}) {
536
560
  const entitiesLib = require("./entities");
537
561
  let packMatches = [];
538
562
  let entityMatches = [];
563
+ const packLimit = packMatchLimit();
539
564
  try {
540
565
  packMatches = mergeMatches(
541
- packsLib.matchPacks(userText, { limit: 3 }),
542
- fullContext ? packsLib.matchPacks(fullContext, { limit: 3 }) : [],
566
+ packsLib.matchPacks(userText, { limit: packLimit }),
567
+ fullContext ? packsLib.matchPacks(fullContext, { limit: packLimit }) : [],
543
568
  (m) => m.dir,
544
569
  );
545
570
  } catch (e) {}
@@ -553,7 +578,7 @@ async function promptWithDynamicContext(prompt, opts = {}) {
553
578
  const candPacks = packMatches;
554
579
  const candEntities = entityMatches;
555
580
  ({ packMatches, entityMatches } = await filterMatches(userText, fullContext, packMatches, entityMatches));
556
- packMatches = packMatches.slice(0, 3);
581
+ packMatches = packMatches.slice(0, packLimit);
557
582
  entityMatches = entityMatches.slice(0, 4);
558
583
  logRecall(userText, candPacks, candEntities, packMatches, entityMatches);
559
584
  const budget = memoryRecallBudget();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inetafrica/open-claudia",
3
- "version": "2.6.22",
3
+ "version": "2.6.23",
4
4
  "description": "Your always-on AI coding assistant — Claude Code, Cursor Agent, and OpenAI Codex via Telegram or Kazee Chat",
5
5
  "main": "bot.js",
6
6
  "bin": {