Skip to content

refactor(db): 消除隐式状态通道,收敛 LLM 上下文消息 - #9

Merged
zavier merged 3 commits into
refactor/dead-interfacefrom
refactor/related-cache-llm-context
Aug 1, 2026
Merged

refactor(db): 消除隐式状态通道,收敛 LLM 上下文消息#9
zavier merged 3 commits into
refactor/dead-interfacefrom
refactor/related-cache-llm-context

Conversation

@zavier

@zavier zavier commented Aug 1, 2026

Copy link
Copy Markdown
Owner

变更内容(3 个 commit)

依赖 PR #8(候选 7)——base 为 refactor/dead-interface,合并后可将 base 改回 main

1. refactor(db): 删除 ready() 并补齐 db_tables 截断

  • 删除 ready() 影子守卫,readiness 由 resolveTarget 单一持有;六个工具统一 getWorkspace() 后走 facade 入口 resolve-and-throw
  • 修复 bugconnection 单独传(无 workspace)时不再被误拒,经 defaultDatabase 正常解析
  • db_relation 缺目标时改抛与 resolveTarget 一致的文案
  • db_tables list 模式补 truncate(),并按场景定制截断提示语(表列表/表结构不再是 query 专用的 "add a LIMIT")

2. refactor(db): 消除隐式状态通道,收敛 LLM 上下文消息

  • lastRelatedCache 从 module 级单例改为注入式 RelatedBrowserCacheStore(db.ts 注册时创建,经调用链传入 query 路径写入、related 路径读取),消除显示函数副作用与测试顺序依赖
  • 新建 commands/llm-context.ts 作为 LLM 英文消息唯一构建点;index.ts / db.ts / switch.ts 三处复用,active 文案统一

3. chore(docs): 修正已实施文档表头,删除过期复现脚本

  • table-tool-consolidation / extension-toggle 表头更新为已实施
  • 删除与 getCompletions 逐字复制的 repro-autocomplete.mjs(真实函数已由 db-command.test.ts 覆盖)

行为变更

  • LLM 收到的 active 消息统一为「当前库 + 配置文件 + Use db_query and db_tables…」
  • db_list_relations 无 workspace 且无 database 时从报错改为列出全部关系

验证

  • npm run check(tsc --noEmit)通过
  • npm test(vitest,223 tests)通过
  • npm run lint(oxlint,0 errors,warnings 15→13)通过
  • npm run fmt / npm run fmt:check 通过

zavier added 3 commits August 1, 2026 20:08
删除 ready() 影子守卫,readiness 由 resolveTarget 单一持有:
- 六个工具统一 getWorkspace() 后走 facade 入口 resolve-and-throw,
  修掉 connection-only 显式目标被误拒的 bug
- db_relation 缺目标时改抛与 resolveTarget 一致的文案

db_tables list 模式补 truncate()(上万张表不再原样灌进上下文),
并按场景定制截断提示语——表列表/表结构不再是 query 专用的
"add a LIMIT" 文案。
候选 8 的两半:
- lastRelatedCache 从 module 级单例改为注入式 RelatedBrowserCacheStore
  (db.ts 注册时创建,经调用链传入 query 路径写入、related 路径读取),
  消除显示函数副作用与测试顺序依赖
- 新建 commands/llm-context.ts 作为 LLM 英文消息的唯一构建点;
  index.ts(session_start)/ db.ts(仪表盘)/ switch.ts(切换后)
  三处复用,active 文案三处统一
table-tool-consolidation / extension-toggle 两份文档表头更新为已实施。
删除与 getCompletions 逐字复制的 repro-autocomplete.mjs——真实函数
已由 __tests__/db-command.test.ts 覆盖,保留只会静默漂移。
@zavier
zavier merged commit 89a1619 into main Aug 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant