@charzhu/openjaw-agent 0.2.4 → 0.2.5

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.
package/dist/main.js CHANGED
@@ -19486,7 +19486,8 @@ var init_user = __esm({
19486
19486
  var memory_exports = {};
19487
19487
  __export(memory_exports, {
19488
19488
  getMemorySection: () => getMemorySection,
19489
- setMemoryPrefetchQuery: () => setMemoryPrefetchQuery
19489
+ setMemoryPrefetchQuery: () => setMemoryPrefetchQuery,
19490
+ shouldSkipPrefetch: () => shouldSkipPrefetch
19490
19491
  });
19491
19492
  import { join as join21 } from "node:path";
19492
19493
  import { homedir as homedir11 } from "node:os";
@@ -19496,8 +19497,48 @@ function setMemoryPrefetchQuery(query) {
19496
19497
  function escapeLike2(token) {
19497
19498
  return `%${token.replace(/[\\%_]/g, "\\$&")}%`;
19498
19499
  }
19500
+ function shouldSkipPrefetch(query) {
19501
+ const trimmed = query.trim();
19502
+ if (trimmed.length === 0) return true;
19503
+ if (/^[\d\s+\-*/().%^=]+$/.test(trimmed)) return true;
19504
+ if (/^[a-z][a-z0-9_-]*( +-{0,2}[a-z0-9_./-]+){0,3}$/.test(trimmed) && trimmed.length <= 32 && !/\s+(my|i|me|the|a|an|alice|bob|carol|dave)\b/i.test(trimmed)) {
19505
+ return true;
19506
+ }
19507
+ const codeMarkers = [
19508
+ /\bfunction\s+\w+\s*\(/,
19509
+ // function foo(
19510
+ /=>/,
19511
+ // arrow fn
19512
+ /\bimport\s+[\w*{]/,
19513
+ // import x
19514
+ /\bfrom\s+['"][\w./-]+['"]/,
19515
+ // from "x"
19516
+ /\bclass\s+\w+/,
19517
+ // class Foo
19518
+ /\bdef\s+\w+\s*\(/,
19519
+ // def foo(
19520
+ /\bconst\s+\w+\s*=/,
19521
+ // const x =
19522
+ /\blet\s+\w+\s*=/,
19523
+ // let x =
19524
+ /\bvar\s+\w+\s*=/,
19525
+ // var x =
19526
+ /\binterface\s+\w+/,
19527
+ // interface Foo
19528
+ /\btype\s+\w+\s*=/
19529
+ // type Foo =
19530
+ ];
19531
+ if (codeMarkers.some((re) => re.test(trimmed))) return true;
19532
+ const hasFileExt = /\b[\w.-]+\.(ts|tsx|js|jsx|mjs|cjs|py|rb|go|rs|java|c|cpp|h|md|json|yaml|yml|toml|sh|ps1|css|scss|html|xml|sql)\b/i.test(trimmed);
19533
+ if (hasFileExt) {
19534
+ const personalSignal = /\b(my|wife|husband|manager|boss|team|alice|bob|carol|dave|remember|usual|standard|default|reply|template|email|outlook|teams|workiq|msvacation|icm|servicenow)\b/i.test(trimmed);
19535
+ if (!personalSignal) return true;
19536
+ }
19537
+ return false;
19538
+ }
19499
19539
  function getMemorySection() {
19500
19540
  if (!currentQuery) return null;
19541
+ if (shouldSkipPrefetch(currentQuery)) return null;
19501
19542
  try {
19502
19543
  const { DatabaseSync: DatabaseSync2 } = __require("node:sqlite");
19503
19544
  const dbPath = join21(homedir11(), ".openjaw", "memory.db");
@@ -19560,8 +19601,8 @@ var MAX_PREFETCH_RESULTS, MAX_PREFETCH_CHARS, MAX_LIKE_TERMS2, STOPWORDS2, curre
19560
19601
  var init_memory2 = __esm({
19561
19602
  "src/prompts/memory.ts"() {
19562
19603
  "use strict";
19563
- MAX_PREFETCH_RESULTS = 10;
19564
- MAX_PREFETCH_CHARS = 4e3;
19604
+ MAX_PREFETCH_RESULTS = 5;
19605
+ MAX_PREFETCH_CHARS = 2e3;
19565
19606
  MAX_LIKE_TERMS2 = 16;
19566
19607
  STOPWORDS2 = /* @__PURE__ */ new Set([
19567
19608
  "a",
@@ -19626,6 +19667,7 @@ var init_memory2 = __esm({
19626
19667
  currentQuery = null;
19627
19668
  __name(setMemoryPrefetchQuery, "setMemoryPrefetchQuery");
19628
19669
  __name(escapeLike2, "escapeLike");
19670
+ __name(shouldSkipPrefetch, "shouldSkipPrefetch");
19629
19671
  __name(getMemorySection, "getMemorySection");
19630
19672
  }
19631
19673
  });