feat: prompt-pack resolution layer (issue #259) - #261
ranxianglei wants to merge 3 commits into
Conversation
Move the pack resolution layer out of the Pi adapter so any host can reuse named surface presets: - Pack/PackSurface/PackSource contracts + sanitizePackSurface - builtin registry (default, lean); lean = host-agnostic compact acpTags section + one-line tool descriptions, host-specific data rides opaquely under adapters.<hostId> - createDirPackSource / createPackResolver / defaultPackSources (project > user dirs > builtin); directory paths stay host policy - pack selection (which name is active) stays adapter-side
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)In your adapter project: npm install acp-kernel@pr-261Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf acp-kernel-pr261.tgz
npm install ./packageThis comment is automatically updated on each push. |
A file lean.json declaring name:custom made listPacks list an unresolvable name. Filename now wins; document trust boundary and per-session caching on createDirPackSource.
|
[bot] 🏷 Independent review pass completed (separate agent, read-only): approve-with-nits, no blockers. Verified: casts in Fixed in 81b2236:
Suite now 713/713 green, typecheck clean. Remaining notes (no action taken):
中文摘要:独立 review 通过(无 blocker),已直接修掉文件名与包名不一致导致 listPacks 列出不可解析名字的问题并补了回归测试,测试 713/713 全绿,可以合并。 |
[bot] 🏷 Review started on PR #261 (head |
…-dependency in dir source list(); wrap overlong PR lines; document packs in README + AGENTS module map
[bot] 🏷 Review complete — mergeable. I checked out the head ( Diff cleanliness (first gate): clean. 7 files, +745/−0 vs base Pre-flight (all run on Node 22, real
Acceptance criteria, verified against code (not just the test claims):
Design audit vs #259: implemented exactly as proposed — Issues found — fixed directly on the branch in
中文摘要:审核通过——diff 干净(7 文件纯新增)、三条验收全部实测复现(typecheck/build 干净、测试 713/713 全绿、lean 经现有 builders 与三种 wire shape 应用无误);已直接在 PR 分支补了一个小修 commit |
What
Moves the prompt-pack resolution layer out of the Pi adapter (local copy shipped in billion-context-pi #397) into acp-kernel, so the billion-context proxy and any future host can consume named surface presets without copying modules.
New module
src/packs/types.ts—Pack/PackSurface/PackSourcecontracts +isValidPackName(rejects traversal/malformed names before any fs access).sanitize.ts—sanitizePackSurface: narrows raw pack JSON into a typed surface over the existing primitives (Promptsrules,CompressPromptSections,NudgePromptSections,ToolPrompts). Unknown keys, wrong types, and empty results are dropped — a bad pack degrades to "no override", never corrupts a good default.adapters.<hostId>is kept opaquely (shallow-copied) as the namespace for host-specific surface data.builtin.ts— builtin registry:default(no overrides) andlean. Lean carries only host-agnostic content: a compact ACP-tags section plus one-line descriptions for all four ACP tools. Compression rules stay default (load-bearing, delivered by builders/nudges); Pi-specific lean surfaces ride underadapters.pi.dir.ts—createDirPackSource(id, dir): one factory for any directory origin,<dir>/<name>.jsonfiles, tolerant of missing dirs and malformed JSON.resolver.ts—createPackResolver(sources)(first non-null wins;listPacksdedupes by name with the same priority) +defaultPackSources({projectDir, userDirs})= project > user dirs (in order) > builtins. Directory paths stay host policy — the kernel never derives them from cwd or homedir.Pack selection (which name is active given the config cascade) stays adapter-side, as proposed in the issue.
Acceptance
src/index.ts), zero new runtime deps (onlynode:fs/node:path, already used bypersist/)buildCompressSystemPrompt/buildCompressTextSystemPrompt/buildCompressHybridSystemPrompt, and the one-line descriptions throughapplyAcpToolOverridesover all three wire shapes (anthropic/openai/responses), with originals verified unmutated and non-matching tools passed through by reference中文摘要:把 prompt-pack 解析层从 Pi 适配器搬进内核(新增
src/packs/*,共 5 个模块 + 测试);lean 包只含主机无关的压缩表面,主机专属数据走不透明的adapters.<hostId>命名空间,目录路径策略留在宿主侧。验收三条全部满足(导出、经现有 builders 应用、712/712 全绿),可以合并;合并后 Pi 适配器可删除本地副本改用内核实现。