cortico-world-hands 0.6.0 → 0.6.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.
Files changed (2) hide show
  1. package/dist/index.js +9 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -21,7 +21,8 @@ var HANDS_DEFAULTS = {
21
21
  honchoBaseUrl: "https://api.honcho.dev",
22
22
  honchoWorkspace: "dsh",
23
23
  honchoPeerId: "morse",
24
- honchoSessionId: "yixin"
24
+ honchoSessionId: "yixin",
25
+ hookGrams: "three"
25
26
  };
26
27
  var KEY_CODES = {
27
28
  back: 4,
@@ -366,10 +367,11 @@ var HOOK_STOP = /* @__PURE__ */ new Set([
366
367
  "\u4E0D\u662F",
367
368
  "\u6CA1\u6709"
368
369
  ]);
369
- function keywordsOf(text, limit = 400) {
370
+ function keywordsOf(text, mode = "both", limit = 400) {
370
371
  const clean = text.replace(/^\[(语音|打字|回答|互动|画面)\]\s*/g, "").replace(/^(主人|mokils)\s*[::]\s*/g, "").replace(/[^\u4e00-\u9fffA-Za-z0-9]/g, "");
371
372
  const out = /* @__PURE__ */ new Set();
372
- for (let n = 2; n <= 4; n += 1) {
373
+ const sizes = mode === "two" ? [2] : mode === "three" ? [3] : [2, 3];
374
+ for (const n of sizes) {
373
375
  for (let i = 0; i + n <= clean.length; i += 1) {
374
376
  const g = clean.slice(i, i + n);
375
377
  if (HOOK_STOP.has(g)) continue;
@@ -379,8 +381,8 @@ function keywordsOf(text, limit = 400) {
379
381
  }
380
382
  return [...out];
381
383
  }
382
- function hookHits(text, rows, limit = 4) {
383
- const grams = keywordsOf(text);
384
+ function hookHits(text, rows, limit = 4, mode = "both") {
385
+ const grams = keywordsOf(text, mode);
384
386
  if (grams.length === 0) return [];
385
387
  const scored = [];
386
388
  for (const row of rows) {
@@ -1657,12 +1659,12 @@ ${lines.join("\n")}`,
1657
1659
  async hookSearch(text) {
1658
1660
  try {
1659
1661
  const rows = await this.hands.memorySearch();
1660
- const hits2 = hookHits(text, rows);
1662
+ const hits2 = hookHits(text, rows, 4, this.opts.cfg.hookGrams ?? "both");
1661
1663
  let diaryHits = [];
1662
1664
  try {
1663
1665
  const diary = await this.hands.diaryList();
1664
1666
  const asRows = diary.map((d) => ({ key: `${d.date}\u300A${d.title}\u300B`, value: d.text }));
1665
- diaryHits = hookHits(text, asRows, 2);
1667
+ diaryHits = hookHits(text, asRows, 2, this.opts.cfg.hookGrams ?? "both");
1666
1668
  } catch {
1667
1669
  }
1668
1670
  if (hits2.length === 0 && diaryHits.length === 0) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "description": "Cortico World: hands for the desktop pet — looks at the phone screen, then taps, swipes, pinches, drags, types and presses keys through whatever actuator the device actually has",
6
6
  "license": "MIT",