refactor(recall): 回执去教学化——尾部操作指引清除,空态一句话,注入头行瘦身

与 schedule 回执同病同治(规范 §六:怎么做写在 schema description,运行时只给事实):

- search 空态:'换个更宽泛的关键词再试,或 op=days…' → '日记中无「q」相关记录。';
  命中数尾巴 '要更多加大 count 或关键词收窄' 删;
- days:'用 op=day 看某天;记得关键词就 op=search' 教学尾行删,头行简化
  '【日记索引】共 N 天(新在前)';空态一句 '日记库为空(尚无收口碎片)。';
- day 空态 '没有日记(当天无交互或条目已裁剪;op=days 可看有哪些天)' → 'date 无日记。';
- files:'(按磁盘实况列出;取内容用 op=link)' 教学尾行删;措辞收紧为
  '「标题」现存文件(顶层 N 个)' / 目录不存在、无文件各一句;
- journalFor 注入头行:五连 op 枚举(search/days/day/files/link 用法)收为
  '(最近N条,非全部——更早的可用 recall 检索)' 一句事实+指针,op 细节归 schema;
- throw 类纠错错误保留(§五:错误是引导修正的合法位置)。

探针 6 项全过(search/days/day/files 零教学、空态一句话、注入头行瘦身)。
This commit is contained in:
2026-09-29 17:31:28 +08:00
parent 4de159c896
commit c5ca2e0bf6
2 changed files with 10 additions and 15 deletions
+2 -5
View File
@@ -76,9 +76,7 @@ function journalFor(db, cfg, user) {
'SELECT session_id, day, text FROM memory_fragments WHERE user = ?' + INJECT_ORDER + ' LIMIT ?'
).all(String(user || ''), cap);
if (!rows.length) return '';
const head = '【长期记忆·日记(最近' + rows.length + '条)】收工时的当日事件摘要,新在前、天内按发生顺序;'
+ '每条【编号】是来源会话 id:更早的日记用 recall 工具 op=search 关键词检索、op=days 按日期翻页再 op=day 取整天;'
+ '那次工作的成果文件用 op=files 查、op=link 取。';
const head = '【长期记忆·日记(最近' + rows.length + '条,非全部——更早的可用 recall 检索)】新在前、天内按发生顺序;每条【编号】是来源会话 id。';
const groups = [];
for (const r of rows) {
const g = groups[groups.length - 1];
@@ -118,8 +116,7 @@ function searchFragments(db, user, query, count) {
if (!hits.length) return '';
hits.sort((a, b) => b.score - a.score || a.i - b.i);
const shown = hits.slice(0, lim);
const parts = ['【日记检索】「' + String(query).trim() + '」命中 ' + hits.length + ' 条,按相关度列前 ' + shown.length + ' 条'
+ (hits.length > shown.length ? ';要更多加大 count 或关键词收窄' : '') + ':'];
const parts = ['【日记检索】「' + String(query).trim() + '」命中 ' + hits.length + ' 条,按相关度列前 ' + shown.length + ' 条:'];
for (const h of shown) parts.push('--- ' + h.r.day + '(' + Math.round(h.score * 100) + '% 匹配)---\n' + renderFrag(h.r));
return parts.join('\n\n');
}
+8 -10
View File
@@ -1379,19 +1379,18 @@ function toolRecall(ctx, args) {
const q = String(args.query || '').trim();
if (!q) throw new Error('op=search 需要 query(关键词;空格分隔多个词更好,如「身份证 水印」)');
const txt = memory.searchFragments(db, user, q, args.count);
return txt || '日记库里没有匹配「' + q + '」的条目。换个更宽泛的关键词再试,或 op=days 看哪天有什么;成果文件走 op=files。';
return txt || '日记中无「' + q + '」相关记录。';
}
case 'days': {
const list = memory.daysIndex(db, user);
if (!list.length) return '日记库是空的:还没有任何收口条目(开场注入的日记也出自这里)。';
return '【日记日期索引】共 ' + list.length + ' 天有记录(新在前):\n' + list.join('\n')
+ '\n用 op=day {date} 看某天的完整日记;记得关键词就直接 op=search。';
if (!list.length) return '日记库为空(尚无收口碎片)。';
return '【日记索引】共 ' + list.length + ' 天(新在前):\n' + list.join('\n');
}
case 'day': {
const date = String(args.date || '').trim();
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) throw new Error('op=day 需要 date(YYYY-MM-DD,先用 op=days 查有哪些天)');
const txt = memory.dayEntry(db, user, date);
return txt ? date + ' 的日记:\n' + txt : date + ' 没有日记(当天无交互或条目已裁剪;op=days 可看有哪些天)。';
return txt ? date + ' 的日记:\n' + txt : date + ' 无日记。';
}
case 'files': {
const t = resolveSession();
@@ -1402,13 +1401,12 @@ function toolRecall(ctx, args) {
.map(d => d.name)
.sort();
} catch (_) {
return '会话「' + t.title + '」的任务目录不存在(已删或未产出),无成果文件。';
return '「' + t.title + '」任务目录不存在,无成果文件。';
}
if (!names.length) return '会话「' + t.title + '」没有成果文件。';
if (!names.length) return '「' + t.title + '」无成果文件。';
const shown = names.slice(0, 80);
return '会话「' + t.title + '」当前存在的文件(' + shown.length + (names.length > shown.length ? '/共 ' + names.length : '') + ' 个):\n'
+ shown.map(n => '- ' + n).join('\n')
+ '\n(按磁盘实况列出:存在即未被删;取内容用 op=link {id, path})';
return '「' + t.title + '」现存文件(顶层 ' + shown.length + (names.length > shown.length ? '/共 ' + names.length : '') + ' 个):\n'
+ shown.map(n => '- ' + n).join('\n');
}
case 'link': {
const t = resolveSession();