caveat-cli 0.19.7 → 0.19.8

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/index.js CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  defaultSelfIdentityTokens,
27
27
  ensureUserConfig,
28
28
  environmentAppliesToTask,
29
- extractPromptCandidates,
29
+ extractSearchWordCandidates,
30
30
  findCaveatHome,
31
31
  findCaveatsForHook,
32
32
  findCaveatsForHookSegments,
@@ -74,7 +74,7 @@ import {
74
74
  userPromptSubmitReminderText,
75
75
  writeDigestMarker,
76
76
  writeUserConfigPatch
77
- } from "./chunk-EMGYSGFX.js";
77
+ } from "./chunk-ITQLGM4K.js";
78
78
 
79
79
  // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js
80
80
  var require_code = __commonJS({
@@ -8390,7 +8390,7 @@ function runStats(ctx) {
8390
8390
 
8391
8391
  // src/commands/serve.ts
8392
8392
  async function runServe(opts) {
8393
- const { startServer } = await import("./server-RSDQNLWE.js");
8393
+ const { startServer } = await import("./server-H4BWLLZ2.js");
8394
8394
  const { port, host } = startServer({ port: opts.port });
8395
8395
  process.stdout.write(`[caveat] web portal: http://${host}:${port}/
8396
8396
  `);
@@ -33237,28 +33237,21 @@ function choice(answer, allowed) {
33237
33237
  return answer.choice;
33238
33238
  }
33239
33239
  function candidateTerms(turns) {
33240
- const seen = /* @__PURE__ */ new Set();
33241
- const terms = [];
33242
- const groups = [...turns].reverse().map((turn) => [turn.user, turn.thinking, turn.assistant].flatMap((part) => extractPromptCandidates(
33243
- part.replace(/(?<=[A-Za-z0-9])(?=[\u3040-\u30ff\u3400-\u9fff])|(?<=[\u3040-\u30ff\u3400-\u9fff])(?=[A-Za-z0-9])/gu, " ")
33244
- )));
33245
- const add = (term) => {
33246
- const key = term.toLocaleLowerCase();
33247
- if (seen.has(key) || terms.length >= MAX_TERMS) return;
33248
- seen.add(key);
33249
- terms.push(term);
33250
- };
33251
- for (const group of groups) {
33252
- let added = 0;
33253
- for (const term of group) {
33254
- const before = terms.length;
33255
- add(term);
33256
- if (terms.length > before) added++;
33257
- if (added === 12) break;
33258
- }
33259
- }
33260
- for (const group of groups) for (const term of group) add(term);
33261
- return terms;
33240
+ const found = /* @__PURE__ */ new Map();
33241
+ let position = 0;
33242
+ for (let turnIndex = 0; turnIndex < turns.length; turnIndex++) {
33243
+ const turn = turns[turnIndex];
33244
+ for (const part of [turn.user, turn.thinking, turn.assistant]) {
33245
+ for (const term of extractSearchWordCandidates(part)) {
33246
+ const key = term.toLocaleLowerCase();
33247
+ const item = found.get(key) ?? { term, turns: /* @__PURE__ */ new Set(), last: 0 };
33248
+ item.turns.add(turnIndex);
33249
+ item.last = position++;
33250
+ found.set(key, item);
33251
+ }
33252
+ }
33253
+ }
33254
+ return [...found.values()].sort((a, b) => b.turns.size - a.turns.size || b.last - a.last).slice(0, MAX_TERMS).map((item) => item.term);
33262
33255
  }
33263
33256
  async function judgeStruggle(key, turns, ask = callJev) {
33264
33257
  const terms = candidateTerms(turns);