@wrongstack/core 0.257.0 → 0.257.2

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,5 +1,5 @@
1
1
  export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, E as EternalAutonomyEngine, c as EternalAutonomyOptions, d as EternalEngineState, H as HybridCompactor, I as IterationStage, P as ParallelEngineState, e as ParallelEternalEngine, f as ParallelEternalOptions, g as ParallelIterationStage, T as ToolExecutor } from '../parallel-eternal-engine-C0juOszP.js';
2
- export { A as AutoCompactionMiddleware, a as AutonomousRunner, b as AutonomousRunnerOptions, c as AutonomyPromptContributorOptions, C as CompactorStrategy, D as DefaultSkillLoader, d as DoneCheckResult, e as DoneConditionChecker, I as IntelligentCompactor, f as IntelligentCompactorOptions, S as SelectiveCompactor, g as SelectiveCompactorOptions, h as SkillLoaderOptions, i as StrategyCompactorOptions, j as buildGoalPreamble, k as createStrategyCompactor, m as makeAutonomyPromptContributor } from '../goal-preamble-UiEkbNmW.js';
2
+ export { A as AutoCompactionMiddleware, a as AutonomousRunner, b as AutonomousRunnerOptions, c as AutonomyPromptContributorOptions, C as CompactorStrategy, D as DefaultSkillLoader, d as DoneCheckResult, e as DoneConditionChecker, I as IntelligentCompactor, f as IntelligentCompactorOptions, S as SelectiveCompactor, g as SelectiveCompactorOptions, h as SkillLoaderOptions, i as StrategyCompactorOptions, j as buildGoalPreamble, k as createStrategyCompactor, m as makeAutonomyPromptContributor } from '../goal-preamble-CznHTZqP.js';
3
3
  import { P as Provider } from '../context-CGdgA0q6.js';
4
4
  import { b as BrainDecision, e as BrainDecisionRequest, B as BrainArbiter } from '../brain-TjEEwSpw.js';
5
5
  import '../retry-policy-Tg7LXkoK.js';
@@ -6655,17 +6655,17 @@ function normalize(text) {
6655
6655
  return ` ${text.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim()} `;
6656
6656
  }
6657
6657
  function scoreAgents(task, catalog = AGENT_CATALOG) {
6658
- const hay = normalize(task);
6658
+ const haySet = new Set(normalize(task).split(/\s+/).filter(Boolean));
6659
6659
  const out = [];
6660
6660
  for (const def of Object.values(catalog)) {
6661
6661
  if (!def?.config?.role) continue;
6662
6662
  let score = 0;
6663
6663
  const matched = [];
6664
6664
  for (const kw of def.capability.keywords) {
6665
- const needle = normalize(kw);
6666
- if (hay.includes(needle.trimEnd() + " ") || hay.includes(" " + needle.trimStart())) {
6667
- const words = kw.trim().split(/\s+/).length;
6668
- score += words;
6665
+ const needleWords = normalize(kw).split(/\s+/).filter(Boolean);
6666
+ const allPresent = needleWords.every((w) => haySet.has(w));
6667
+ if (allPresent) {
6668
+ score += needleWords.length;
6669
6669
  matched.push(kw);
6670
6670
  }
6671
6671
  }
@@ -8471,6 +8471,8 @@ function compactSkillBody(body) {
8471
8471
  var DefaultSkillLoader = class {
8472
8472
  dirs;
8473
8473
  cache;
8474
+ entriesCache;
8475
+ bodyCache = /* @__PURE__ */ new Map();
8474
8476
  constructor(opts) {
8475
8477
  this.dirs = [
8476
8478
  { dir: opts.paths.inProjectSkills, source: "project" },
@@ -8529,6 +8531,7 @@ var DefaultSkillLoader = class {
8529
8531
  return lines.join("\n");
8530
8532
  }
8531
8533
  async listEntries() {
8534
+ if (this.entriesCache) return this.entriesCache;
8532
8535
  const skills = await this.list();
8533
8536
  const entries = [];
8534
8537
  for (const s of skills) {
@@ -8539,33 +8542,47 @@ var DefaultSkillLoader = class {
8539
8542
  } catch {
8540
8543
  }
8541
8544
  }
8545
+ this.entriesCache = entries;
8542
8546
  return entries;
8543
8547
  }
8544
8548
  invalidateCache() {
8545
8549
  this.cache = void 0;
8550
+ this.entriesCache = void 0;
8551
+ this.bodyCache.clear();
8546
8552
  }
8547
8553
  async readBody(name) {
8554
+ const cached = this.bodyCache.get(name);
8555
+ if (cached !== void 0) return cached;
8548
8556
  const m = await this.find(name);
8549
8557
  if (!m) throw new Error(`Skill "${name}" not found`);
8550
- return fs.readFile(m.path, "utf8");
8558
+ const body = await fs.readFile(m.path, "utf8");
8559
+ this.bodyCache.set(name, body);
8560
+ return body;
8551
8561
  }
8552
8562
  async readSaveBody(name) {
8563
+ const key = `save:${name}`;
8564
+ const cached = this.bodyCache.get(key);
8565
+ if (cached !== void 0) return cached;
8553
8566
  const m = await this.find(name);
8554
8567
  if (!m) throw new Error(`Skill "${name}" not found`);
8555
8568
  const savePath = path2.join(path2.dirname(m.path), "SKILL.save.md");
8569
+ let result;
8556
8570
  try {
8557
- return await fs.readFile(savePath, "utf8");
8571
+ result = await fs.readFile(savePath, "utf8");
8558
8572
  } catch {
8559
8573
  const full = await fs.readFile(m.path, "utf8");
8560
8574
  const body = stripFrontmatter(full);
8561
8575
  const compact = compactSkillBody(body);
8562
8576
  if (compact) {
8563
- return `## Overview
8577
+ result = `## Overview
8564
8578
 
8565
8579
  ${compact}`;
8580
+ } else {
8581
+ result = body.trim().slice(0, 300);
8566
8582
  }
8567
- return body.trim().slice(0, 300);
8568
8583
  }
8584
+ this.bodyCache.set(key, result);
8585
+ return result;
8569
8586
  }
8570
8587
  };
8571
8588
  function parseFrontmatter(raw) {