mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
feat: 系统提示词改为单一入口统一管理
多个扩展各自整段改写系统提示词并按加载顺序接力,任一扩展定死提示词后 其余只能做字符串手术,且各上游的工具说明与组合包实际工具格局冲突。 - 新增 extensions/system-prompt.ts 作为唯一出口(加载列表最后),按 config/prompt/(preamble.md、tools.jsonc、routing.jsonc、sections.jsonc) 组合开场白、工具简介/规则与 <tool_routing> 分区;替代原封面与 tool-routing 扩展,/dump-system-prompt 输出最终提示词。 - pi-chrome、pi-ssh、pi-hermes-memory 改为写命名分区,pi-rtk-optimizer 改写 promptGuidelines,pi-permission-system 直接过滤结构化 skills, 均不再返回 systemPrompt;pi-chrome 未授权时不再每轮冻结提示词。 - 新增 prompt-guard 代理加载第三方扩展(Hashline、FFF、LSP、 context-mode):拦截直接改写提示词并按目录覆盖工具说明;context-mode 去掉与组合包路由冲突的锚点段,保留记忆与恢复快照。 - 消除冲突:bash 简介不再建议 grep/find;Hashline edit 不再称可用 grep 锚点、不再介绍已关闭的 replace_text;context-mode 读写/网页路由提示。 - 守门测试:工具目录覆盖率、禁用用法检查、context-mode 上游原文锁定; AGENTS.md 新增「系统提示词单一所有权」。 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
dc4fe92e27
commit
ba164896d2
@@ -1,4 +1,5 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync } from "node:fs";
|
||||
import { mkdir, mkdtemp, readFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
@@ -154,17 +155,44 @@ test("all package extensions load together without global registration conflicts
|
||||
packageJson.pi.extensions.includes("./pi-hermes-memory/src/index.ts"),
|
||||
"the bundle must load the locally maintained Hermes memory extension",
|
||||
);
|
||||
// The cover must rewrite the prompt before tool-routing flattens it into a forced prompt;
|
||||
// once flattened, later handlers cannot restore the section structure.
|
||||
// extensions/system-prompt.ts is the bundle's single system-prompt owner and
|
||||
// must run after every tool-registration extension (including Tool Search)
|
||||
// so it sees the complete tool set and any contributed sections.
|
||||
assert.equal(
|
||||
packageJson.pi.extensions.at(-1),
|
||||
"./extensions/system-prompt.ts",
|
||||
"the single system-prompt owner must be the last loaded extension",
|
||||
);
|
||||
assert.ok(
|
||||
packageJson.pi.extensions.includes("./extensions/context-mode.ts"),
|
||||
"Context Mode must load through the bundle's prompt-guarded wrapper",
|
||||
);
|
||||
assert.equal(
|
||||
packageJson.pi.extensions.some((entry) => entry.includes("context-mode/build/")),
|
||||
false,
|
||||
"the raw Context Mode adapter must not be loaded alongside the wrapper",
|
||||
);
|
||||
assert.equal(
|
||||
packageJson.pi.extensions.includes("./extensions/system-prompt-cover.ts"),
|
||||
"the bundle must load the system prompt cover extension",
|
||||
false,
|
||||
"the retired system-prompt cover must not be loaded",
|
||||
);
|
||||
assert.ok(
|
||||
packageJson.pi.extensions.indexOf("./extensions/system-prompt-cover.ts") <
|
||||
packageJson.pi.extensions.indexOf("./extensions/tool-routing.ts"),
|
||||
"the system prompt cover must run before tool-routing forces the prompt",
|
||||
assert.equal(
|
||||
packageJson.pi.extensions.includes("./extensions/tool-routing.ts"),
|
||||
false,
|
||||
"the retired tool-routing extension must not be loaded",
|
||||
);
|
||||
for (const retired of [
|
||||
"extensions/system-prompt-cover.ts",
|
||||
"extensions/system-prompt-cover-config.ts",
|
||||
"extensions/tool-routing.ts",
|
||||
]) {
|
||||
assert.equal(
|
||||
existsSync(join(repositoryRoot, retired)),
|
||||
false,
|
||||
`${retired} was superseded by extensions/system-prompt.ts and must be deleted`,
|
||||
);
|
||||
}
|
||||
assert.equal(packageJson.dependencies["pi-hermes-memory"], "file:./pi-hermes-memory");
|
||||
assert.ok(
|
||||
packageJson.files.includes("pi-hermes-memory"),
|
||||
|
||||
Reference in New Issue
Block a user