Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ For each request, the proxy resolves the settings by longest-URL-prefix match (t
- **Type:** `string` (pack name, e.g. `"lean"`)
- **Default:** `default` *(unset is equivalent — identity surface, kernel defaults everywhere)*
- **Status:** ACTIVE
- **Description:** Select a named prompt pack — a curated surface preset covering tool descriptions, compress system-prompt sections, and nudge sections — resolved from the host's pack chain: **project** `./.billion-context/packs/<name>.json` → **user** `<configDir>/packs/<name>.json` → **shipped** (`chat`) → **builtin** (`default`, `lean`). Built-in `lean` swaps the four ACP tool descriptions for one-liners (no snippet/guideline chrome) while keeping the compression rules default. Built-in `chat` (#5319) rewrites only the compress philosophy and how-to-compress prose for long-term companionship / multi-session memory use; every other surface piece stays at the host defaults, and a same-name user or project file overrides it. Unknown names fall back to the identity surface with a one-time warning. Same three-level merge as the other fields; pack-surface sections (tool/section overrides) apply directly, without the `acknowledgePromptsRisk` gate — that gate governs only inline `compress.prompts` rule-text overrides. Note a pack's `prompts` block is ignored by this proxy: rule-text overrides are possible only via inline `compress.prompts`. Requires `acp-kernel` >= 0.0.66. The settings panel can manage the user-dir files directly — New/Edit/Delete for packs under `<configDir>/packs/` (the picker knows each entry's provenance; builtins and shipped packs stay read-only there, override them with a same-named user pack instead).
- **Description:** Select a named prompt pack — a curated surface preset covering tool descriptions, compress system-prompt sections, and nudge sections — resolved from the host's pack chain: **project** `./.billion-context/packs/<name>.json` → **user** `<configDir>/packs/<name>.json` → **shipped** (`chat`) → **builtin** (`default`, `lean`). Built-in `lean` swaps the four ACP tool descriptions for one-liners (no snippet/guideline chrome) while keeping the compression rules default. Built-in `chat` (#5319) rewrites only the compress philosophy and how-to-compress prose for long-term companionship / multi-session memory use; every other surface piece stays at the host defaults, and a same-name user or project file overrides it. Unknown names fall back to the identity surface with a one-time warning. Same three-level merge as the other fields; pack-surface sections (tool/section overrides) apply directly, without the `acknowledgePromptsRisk` gate — that gate governs only inline `compress.prompts` rule-text overrides. Note a pack's `prompts` block is ignored by this proxy: rule-text overrides are possible only via inline `compress.prompts`. Requires `acp-kernel` >= 0.0.66. The settings panel can manage the user-dir files directly — New/Edit/Delete for packs under `<configDir>/packs/` (the picker knows each entry's provenance; builtins and shipped packs stay read-only there, override them with a same-named user pack instead). The Edit dialog has three tabs (#5344): **Guided form** — per-field help text plus one-click base text loaded from `default`/`chat`/`lean` (empty fields are omitted and fall back to system defaults at runtime); **AI assist** — describe your scenario in plain words, copy the generated prompt to any LLM, paste its JSON back and it parses straight into the form; **Advanced (JSON)** — raw file text for full control.

**Pack file format.** Each `<dir>/<name>.json` holds one pack object. Unknown fields are dropped by the same sanitizer used on every load path (`sanitizePackSurface`), so extra metadata is harmless:

Expand Down
2 changes: 1 addition & 1 deletion CONFIGURATION.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ ACP 原生 agent(当前为 `pi` 扩展)会在每个进程内向代理上报
- **类型:** `string`(包名,如 `"lean"`)
- **默认值:** `default`(未设置等同——恒等表面,全部使用内核默认值)
- **状态:** ACTIVE
- **说明:** 选择一个具名 prompt pack —— 一套策划好的表面预设,覆盖工具描述、压缩系统提示词段落、nudge 段落 —— 从宿主侧的包解析链解析:**项目** `./.billion-context/packs/<name>.json` → **用户** `<configDir>/packs/<name>.json` → **随包附带**(`chat`)→ **内核内置**(`default`、`lean`)。内置 `lean` 把四个 ACP 工具描述换成单行版(无 snippet/guideline 包装),压缩规则保持默认。内置 `chat`(#5319)只替换压缩哲学段与 how-to-compress 规则段,面向长期陪伴 / 多会话记忆场景;其余表面全部保持宿主默认,同名的用户/项目文件会覆盖它。未知包名回退到恒等表面并记录一次警告。与其他字段一样三级级联合并;包的表面覆盖(工具/段落)直接生效,不经 `acknowledgePromptsRisk` 门控——该门控只管内联 `compress.prompts` 的规则文本覆盖。注意:包文件里的 `prompts` 块会被本代理忽略,规则文本只能经内联 `compress.prompts` 设置。需要 `acp-kernel` >= 0.0.66。设置面板可以直接管理用户目录里的包文件——对 `<configDir>/packs/` 下的包 新建/编辑/删除(选择器知道每个条目的来源;内置与 shipped 包在那里只读,要用同名用户包覆盖)。
- **说明:** 选择一个具名 prompt pack —— 一套策划好的表面预设,覆盖工具描述、压缩系统提示词段落、nudge 段落 —— 从宿主侧的包解析链解析:**项目** `./.billion-context/packs/<name>.json` → **用户** `<configDir>/packs/<name>.json` → **随包附带**(`chat`)→ **内核内置**(`default`、`lean`)。内置 `lean` 把四个 ACP 工具描述换成单行版(无 snippet/guideline 包装),压缩规则保持默认。内置 `chat`(#5319)只替换压缩哲学段与 how-to-compress 规则段,面向长期陪伴 / 多会话记忆场景;其余表面全部保持宿主默认,同名的用户/项目文件会覆盖它。未知包名回退到恒等表面并记录一次警告。与其他字段一样三级级联合并;包的表面覆盖(工具/段落)直接生效,不经 `acknowledgePromptsRisk` 门控——该门控只管内联 `compress.prompts` 的规则文本覆盖。注意:包文件里的 `prompts` 块会被本代理忽略,规则文本只能经内联 `compress.prompts` 设置。需要 `acp-kernel` >= 0.0.66。设置面板可以直接管理用户目录里的包文件——对 `<configDir>/packs/` 下的包 新建/编辑/删除(选择器知道每个条目的来源;内置与 shipped 包在那里只读,要用同名用户包覆盖)。编辑对话框有三个页签(#5344):**表单填写**——逐字段说明文字,可一键载入 `default`/`chat`/`lean` 的现有文案做起稿底本(留空字段不写入包文件,运行时沿用系统默认);**AI 辅助**——用大白话描述使用场景,把生成的提示词复制到任意大模型执行,再把返回的 JSON 粘回来即可自动填入表单;**高级(JSON)**——原始文件文本,给需要完整控制的用户。

**包文件格式。** 每个 `<dir>/<name>.json` 是一个 pack 对象。未识别的字段会被与所有加载路径相同的 sanitize 器丢弃(`sanitizePackSurface`),所以多写元数据无害:

Expand Down
5 changes: 4 additions & 1 deletion src/server/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { formatUpstreamError, getUpstreamConnectionStatus, proxyDispatcher, reco
import { detectStaleInstall, getLastInstall } from "../update.js";
import { getPlannedUpgrade, getUpdatePolicyState } from "../update-policy.js";
import { PACKAGE_NAME, VERSION, BUILD_COMMIT } from "../version.js";
import { buildBlockContent, buildMessageContent, buildOverview, buildSessionDetail, buildSessionList, buildSessionPage, buildSessionTree, handleConfigGet, handleConfigPut, handlePricingGet, handleUserPackDelete, handleUserPackGet, handleUserPackPut, hiddenEmptyCount, renderUI, type BlockContentView } from "../web/index.js";
import { buildBlockContent, buildMessageContent, buildOverview, buildSessionDetail, buildSessionList, buildSessionPage, buildSessionTree, handleConfigGet, handleConfigPut, handlePackTemplatesGet, handlePricingGet, handleUserPackDelete, handleUserPackGet, handleUserPackPut, hiddenEmptyCount, renderUI, type BlockContentView } from "../web/index.js";
import { handleChangelogGet } from "../web/changelog.js";
import { kickBlogRefresh } from "../web/blog-refresh.js";
import { handleBlogAssetGet, handleBlogGet } from "../web/blogfeed.js";
Expand Down Expand Up @@ -348,6 +348,9 @@ export async function handleAdminRoute(req: http.IncomingMessage, res: http.Serv
res.end(JSON.stringify({ packs, userDir: path.join(configDir(), "packs") }));
return;
}
// #5344: base texts for the guided pack-editor form (tri-state resolved
// exactly like buildCompressSystemPrompt). Read-only; same gates.
if (req.method === "GET" && req.url === "/__bili/packs/templates") return handlePackTemplatesGet(res);
// #5328: user-dir pack management — GET/PUT/DELETE <configDir>/packs/
// <name>.json. The route regex shapes the name to the pack-name charset
// ([A-Za-z0-9][A-Za-z0-9._-]*) before dispatch; the handlers re-validate
Expand Down
28 changes: 27 additions & 1 deletion src/web/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { dirname, join } from "node:path";
import { randomUUID } from "node:crypto";
import type { IncomingMessage, ServerResponse } from "node:http";
import { configDir, configFile } from "../paths.js";
import { isValidPackName, sanitizePackSurface, type PromptPackFile } from "acp-kernel";
import { defaultPrompts, isValidPackName, sanitizePackSurface, type PromptPackFile } from "acp-kernel";
import { resolveCompressSurfaceDetailed } from "../compress-settings.js";
import {
collectNamedProviders,
loadNamedProviders,
Expand Down Expand Up @@ -172,6 +173,31 @@ export async function handleUserPackDelete(res: ServerResponse, name: string): P
res.end(JSON.stringify({ ok: true }));
}

// #5344: base texts for the guided pack editor (form tab). Mirrors the
// tri-state resolution buildCompressSystemPrompt performs: absent key ->
// kernel default text; null -> removed (empty); string -> verbatim.
const PACK_TEMPLATE_NAMES = ["default", "chat", "lean"] as const;
type PackTemplate = { description?: string; philosophy: string; howToCompress: string };

function packTemplateFor(name: string): PackTemplate {
const resolution = resolveCompressSurfaceDetailed({ promptPack: name });
const sections = resolution.surface.promptSections ?? {};
const pick = (key: "philosophy" | "howToCompress"): string => {
const override = sections[key];
if (override === null) return "";
if (typeof override === "string") return override;
return key === "philosophy" ? defaultPrompts.compressPhilosophy : defaultPrompts.howToCompressRules;
};
return { philosophy: pick("philosophy"), howToCompress: pick("howToCompress") };
}

export async function handlePackTemplatesGet(res: ServerResponse): Promise<void> {
const packs: Record<string, PackTemplate> = {};
for (const name of PACK_TEMPLATE_NAMES) packs[name] = packTemplateFor(name);
res.writeHead(200, { "content-type": "application/json" });
res.end(JSON.stringify({ packs }));
}

export async function handleConfigGet(res: ServerResponse): Promise<void> {
const upstream = readUpstreamSettings();
const config = readConfig();
Expand Down
Loading
Loading