feat: update database documentation and remove reference field guide from prompts
This commit is contained in:
1 parent
0a9edc0a74
commit
4ab6f25241
4 files changed
+8
-42
No files matched your search
+1
-1
@@ -54,7 +54,7 @@ SQLite 保存以下业务数据:
|
||||
|
||||
- 当前代码支持的最终 schema version 是 `10`,由 `CURRENT_SCHEMA_VERSION` 定义。
|
||||
- version `1–9` 已随正式版发布,永久保留且不可改写。已知历史例外只有 version 2 的旧名称 `workspace_change_sets`;version 9 继续负责修复通知字段。
|
||||
- version `10` 是破坏性升级,不迁旧数据。`upgrade_from_v9` 从 v9 升级时 DROP 旧表再建最终结构:新增 `partner`;删除 `chat_session`、`chat_session_ui_state`(以及 `chat_conversation_memory`、`chat_session_resume_snapshot`、`ai_run_event`、`chat_session_skill_state`、`chat_message`);`chat_session_message_log` / `ai_run` / `ai_file_change` / `docx_apply` 改挂 `partner_id`;新增 `partner_ui_state`;`workbench_ui_state` 只留 `active_view_key`,删除 `draft_state_json`;`scheduled_task` 改挂 `partner_id`;`workspace_source` 去掉 name 且 `root_path UNIQUE`;`web_source` 去掉 `workspace_id` 且 `UNIQUE(normalized_url)`;`ai_run` 不再保存 `workspace_json`。不存在、也不新建 `chat_search_turn`。空库仍执行 version `1–10`,跑完后结构与 v9 升级路径一致。
|
||||
- version `10` 是破坏性升级,不迁旧数据。`upgrade_from_v9` 从 v9 升级时 DROP 旧表再建最终结构:新增 `partner`;删除 `chat_session`、`chat_session_ui_state`(以及 `chat_conversation_memory`、`chat_session_resume_snapshot`、`ai_run_event`、`chat_session_skill_state`、`chat_message`);`chat_session_message_log` / `ai_run` / `ai_file_change` / `docx_apply` 改挂 `partner_id`;新增 `partner_ui_state`;`workbench_ui_state` 只留 `active_view_key`,删除 `draft_state_json`;`scheduled_task` 改挂 `partner_id`;`workspace_source` 去掉 name 且 `root_path UNIQUE`;`web_source` 去掉 `workspace_id` 且 `UNIQUE(normalized_url)`;`ai_run` 不再保存 `workspace_json`。不存在、也不新建 `chat_search_turn`。空库仍执行 version `1–10`,跑完后结构与 v9 升级路径一致。LanceDB 不在 SQLite migration 事务里;v10 清空 `document` 后旧 chunk 会成为孤儿,检索按 SQLite 有效 generation 过滤,不会命中。不在启动路径删除 `userData/lancedb`。
|
||||
- 哪些 migration 已正式发布,以 `migrations/released-migrations.json` 为唯一边界。未进入清单的连续迁移可以在发布前合并或重写;进入清单后只能新增更高版本修复。
|
||||
|
||||
### 版本身份与执行规则
|
||||
|
||||
@@ -69,12 +69,6 @@ ${external.map((skill) => renderSkillLine(skill.skillId, skill.description, skil
|
||||
`.trim()
|
||||
}
|
||||
|
||||
const REFERENCE_FIELD_GUIDE = `字段说明:
|
||||
- 类型:资料来源类型,目前支持本地文件、本地目录、网页资料。
|
||||
- 资源地址:这份资料对应的本地路径或网页地址。
|
||||
- 文档知识库状态:这份资料本身是否可被知识库检索。
|
||||
- 知识库文档ID:这份资料在知识库中的文档标识;没有对应知识库文档时显示为“无”。`
|
||||
|
||||
export const buildBrainSystemPrompt = (input: { ctx: AiRunContext }): string =>
|
||||
`
|
||||
<system>
|
||||
@@ -120,10 +114,6 @@ export const buildBrainSystemPrompt = (input: { ctx: AiRunContext }): string =>
|
||||
${renderSkillCatalog(input.ctx.platform)}
|
||||
</skill_catalog>
|
||||
|
||||
<reference_field_guide>
|
||||
${REFERENCE_FIELD_GUIDE}
|
||||
</reference_field_guide>
|
||||
|
||||
<local_environment>
|
||||
${renderLocalEnvironmentText(input.ctx)}
|
||||
</local_environment>
|
||||
|
||||
@@ -49,6 +49,8 @@ describe('ai unit brain prompt formatting', () => {
|
||||
expect(environment).toContain('runtime_paths.assets:')
|
||||
expect(environment).not.toContain('current_time')
|
||||
expect(system).not.toContain('current_time.local_iso')
|
||||
expect(system).not.toContain('reference_field_guide')
|
||||
expect(system).not.toContain('字段说明')
|
||||
})
|
||||
|
||||
it('keeps context efficiency and planning rules concise', () => {
|
||||
|
||||
@@ -5,35 +5,24 @@ import {
|
||||
} from '../../../../src/main/services/ai/human/prompts/referenceScope'
|
||||
|
||||
describe('ai unit selected context workspace path', () => {
|
||||
it('renders workspace rootPath without a workspace-only path restriction', () => {
|
||||
it('does not render workspace roots inside reference scope', () => {
|
||||
const text = renderReferenceScopeText(
|
||||
buildReferenceScope({
|
||||
workspace: {
|
||||
workspaceId: 'workspace-1',
|
||||
workspaceName: 'display-name-only',
|
||||
rootPath: '/tmp/real-workspace-root'
|
||||
},
|
||||
selectedReferences: []
|
||||
})
|
||||
)
|
||||
|
||||
expect(text).toContain('用户工作区域:')
|
||||
expect(text).toContain('- 根目录:/tmp/real-workspace-root')
|
||||
expect(text).toContain('用户指定的参考范围:')
|
||||
expect(text).toContain('- 当前没有用户显式指定的参考范围。')
|
||||
expect(text).not.toContain('用户工作区域:')
|
||||
expect(text).not.toContain('根目录:')
|
||||
expect(text).not.toContain('默认应优先在此目录内完成用户任务')
|
||||
expect(text).not.toContain('所有任务文件和新生成的产物都必须位于这个工作区内')
|
||||
expect(text).not.toContain('display-name-only')
|
||||
expect(text).not.toContain('cwd')
|
||||
expect(text).not.toContain('显式指定 cwd')
|
||||
})
|
||||
|
||||
it('renders selected references and direct kb narrowing pairs when user explicitly selected inputs', () => {
|
||||
const text = renderReferenceScopeText(
|
||||
buildReferenceScope({
|
||||
workspace: {
|
||||
workspaceId: 'workspace-1',
|
||||
workspaceName: 'display-name-only',
|
||||
rootPath: '/tmp/real-workspace-root'
|
||||
},
|
||||
selectedReferences: [
|
||||
{
|
||||
kind: 'file',
|
||||
@@ -56,11 +45,6 @@ describe('ai unit selected context workspace path', () => {
|
||||
expect(
|
||||
renderReferenceScopeText(
|
||||
buildReferenceScope({
|
||||
workspace: {
|
||||
workspaceId: 'workspace-1',
|
||||
workspaceName: 'display-name-only',
|
||||
rootPath: '/tmp/real-workspace-root'
|
||||
},
|
||||
selectedReferences: [
|
||||
{
|
||||
kind: 'directory',
|
||||
@@ -90,11 +74,6 @@ describe('ai unit selected context workspace path', () => {
|
||||
expect(
|
||||
renderReferenceScopeText(
|
||||
buildReferenceScope({
|
||||
workspace: {
|
||||
workspaceId: 'workspace-1',
|
||||
workspaceName: 'display-name-only',
|
||||
rootPath: '/tmp/real-workspace-root'
|
||||
},
|
||||
selectedReferences: [
|
||||
{
|
||||
kind: 'web',
|
||||
@@ -116,11 +95,6 @@ describe('ai unit selected context workspace path', () => {
|
||||
it('renders user selected attachments with compact content-info template', () => {
|
||||
const text = renderReferenceScopeText(
|
||||
buildReferenceScope({
|
||||
workspace: {
|
||||
workspaceId: 'workspace-1',
|
||||
workspaceName: 'display-name-only',
|
||||
rootPath: '/tmp/real-workspace-root'
|
||||
},
|
||||
selectedReferences: [],
|
||||
attachments: [
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user