Repository navigation
[PR] (ai: anthropic/claude-opus-4-6) Manage custom compressed prompt packs on the web: Create / Edit / Delete | (ai: anthropic/claude-opus-4-6) 网页端管理自定义压缩提示词包:新建 / 编辑 / 删除 - #5331
Merged
Conversation
…5319) GET /__bili/packs returns every pack the resolver can see (project > user > shipped > builtin, first-wins per name) with provenance; the settings panel's promptPack dropdown now renders those names instead of hardcoded default+lean, with a note line for the shipped chat pack. Unchanged behavior until loadConfig fills the list (falls back to the old two options on fetch failure). listResolvedPacks() shares the exact chain builder with per-request resolution. Co-authored-by: qwen3.8-27b <agent@billion-context.local>
Add New/Edit/Delete for custom compress prompt packs under `~/.config/billion-context/packs/` so users never need a terminal or a file path: - GET/PUT/DELETE /__bili/packs/user/<name> (api.ts) — same loopback + trusted-origin gates as every other /__bili/ route; names shaped by the route regex AND re-validated with the kernel's isValidPackName; payloads parsed + sanitized exactly like dir-pack loading (bad JSON, non-object top level, or surfaces without recognized fields are refused before touching disk); writes go through the existing atomic temp-file+rename pattern. - GET /__bili/packs gains userDir so the panel knows which listed entries it may edit (server authority on the directory). - Panel picker row: name field + New/Edit/Delete + inline JSON editor; Edit/Delete only act on user-dir packs — builtins/shipped/project packs get override guidance instead; saving auto-selects the pack. - i18n zh-CN/en; CONFIGURATION(.zh-CN).md note under promptPack. - tests/web-user-packs.test.ts: create/read/delete round-trip, unknown keys preserved for host adapters, refused payloads leave no file, dotted/traversal names rejected. Branch note: stacked directly on 171417c (#5325, web half of #5319); #5325 merges first or together, both orderings stay conflict-free.
Contributor
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.7482-pr.5331.9b581b6This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5331.tgz
npm install -g packageInstall instructions are refreshed on each push. |
This was referenced Oct 31, 2026
…acks (#5340) Final piece of the pack workstream (#5319 item ④): a documented standard pack format plus a first-class way to install other people's packs. Convention: an npm package is installable as a prompt pack when its root contains bili-pack.json (the same object shape as any `~/.config/billion-context/packs/<name>.json`). `bili pack install <spec>` delegates to the local `npm` in a throwaway sandbox and reads that one file out — registry auth, version ranges, scoped names, git URLs and .tgz paths all behave like a normal npm install; no tar parsing, no new dependency. - src/pack-install.ts: installPackFromNpm/removePackFile/packDirFor. Kernel-shaped validation end to end (isValidPackName, sanitizePackSurface + non-empty surface check shared with the web handler via the now-exported packSurfaceHasContent), atomic temp-file+rename writes, default destination <configDir>/packs, --project targets ./.billion-context/packs/, existing files are never overwritten without --force. - cli.ts: `bili pack install <npm-spec> [--project] [--force]` / `remove <name>` / `list` (also accepts plural `packs`); list prints every resolvable pack with version and provenance. - docs: CONFIGURATION.md + zh-CN gain the full pack file format section (annotated example, tri-state null semantics, sanitize behavior) and publish/install instructions. - tests/pack-install.test.ts: local-directory npm specs keep the suite offline — install→resolvable round-trip, force semantics, missing entry file, invalid names, empty surfaces, remove errors, dir targets. Verified live against dist: list shows builtin/shipped packs, install from a real package dir lands in the XDG packs dir, reinstall refuses without --force, remove cleans up. Branch note: stacked on #5331 (web half) and its base #5325 — the code reuses their exported helpers; merge bottom-up.
Contributor
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.956-master.d108df3 # this exact build
npm install -g billion-context@master # always the newest merged build
|
ranxianglei
added a commit
that referenced
this pull request
Oct 31, 2026
…used-export gate) Upstream PR #5331 (merged 09:35Z today) introduced src/pack-install.ts with an export nobody references outside the defining file — installPackFromNpm's callers pass options structurally, so the guard verdict is INTERNAL_ONLY and its own suggested remedy applies: drop the leading `export`. This merge-ref regression would fail every open PR's unused-exports job (and master's next push CI); fixing it here so the suite goes fully green. Content otherwise byte-identical to master.
This was referenced Oct 31, 2026
ranxianglei
added a commit
that referenced
this pull request
Oct 31, 2026
Previous head conflicted (add/add on src/pack-install.ts): this branch pre-dated PR #5331, which added that file to master while the branch carried its own copy. Sandbox cannot clone full objects, so the branch is reconstructed as one clean commit on today's master via the Git data API. Contents unchanged from the reviewed work: workflows - ci-janitor: feed the sweep loop its run list (it was never wired up — zombie cancels were dead code since 10-30); add backlog breaker (starvedQueueLimit warn + starvedQueuedMaxMinutes pruning, push-to-master exempt) - concurrency groups: master-build, release, release-kernel (no-cancel), theorem (skip-lane suffix per house rules) - timeout-minutes on six workflows left on the 6h default (release 90, release-kernel 90, release-bugfix 90, release-manual 90, advisories 30, pages 30, ci-gate-plugins 30) master-reds fixed here so every gate passes - LIFECYCLE.md: register BILI_SPAWN_FINGERPRINT (#5303/#4125) and BILI_SESSION_CONTENT_STORE_PIN (#5292 phase2) - src/codex-models.ts: drop unused `export` on CodexWindowSource (zero named references; tsconfig has no declaration emit) - CONFIGURATION{,.zh-CN}.md: restore promptPack row to generator output ("chat" is host-shipped, not builtin; follow-up for #5320: add chat to website/config-reference/compress.yaml and regenerate) - src/pack-install.ts: PackInstallOptions -> internal (callers pass options structurally) latent test fixes (surfaced once gates went green) - src/launcher.ts: #4125 rewrite dropped the phrase tests/issue5103 asserts verbatim; restored - tests/store.test.ts: move fault injection to the real write point so adopt() runs before the disk sabotage
ranxianglei
added a commit
that referenced
this pull request
Oct 31, 2026
…E rows Previous head shadowed ~20 lines of #5331's pack-install docs section inside the two configuration tables and duplicated two BILI_* ledger rows master has since registered itself. Restore all three files onto today's master text: only the promptPack table row reverts to generator output ("chat" is host-shipped, not builtin); LIFECYCLE.md back to exact master bytes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5328
Refs #5319(pack 总需求)、#5325(面板动态列表)
这是什么
compress.promptPack早就支持从~/.config/billion-context/packs/加载自定义包,但网页端只有"选"没有"管"——新建一个包、改一句规则、删一个旧包都得退出页面找文件手改 JSON。本 PR 在选择器旁加了一行 新建 / 编辑当前所选 / 删除当前所选 按钮和一个内联 JSON 编辑器:填包名、写 JSON、保存,文件原子落盘到~/.config/billion-context/packs/<name>.json并自动切换为它。内置default/lean/chat与项目目录包在这里只读,界面给出对应指引(内置用同名用户包覆盖)。改动
src/web/api.tsGET/PUT/DELETE /__bili/packs/user/<name>。名字过路由正则 + 内核isValidPackName双校验;payload 按 dir-pack 同款解析+sanitize,坏 JSON / 非对象顶层 / 无任何有效字段的包在写盘前拒绝;未知顶层键(host adapter 用)原样保留;写盘走既有 temp-file+rename 原子范式src/server/admin.tsGET /__bili/packs增加userDir字段(服务端说了算,面板据此判断哪些条目可编辑)src/web/client.tssrc/web/i18n.tsCONFIGURATION.md/.zh-CN.mdtests/web-user-packs.test.tsKernel Boundary
不涉及
kernel/**。仅调用 kernel 已导出的isValidPackName/sanitizePackSurface(与 dir-pack 加载同一套语义),未改动任何 kernel 行为。Config surface
无新配置字段。
compress.promptPack本身不变;新增的是对"用户目录里那个包文件"的管理通道,保存后的效果等价于用户自己手写该文件。双模式推理(proxy / plugin)
Preflight / 验证
npm run typecheckclean;node --check校验内嵌 WEB_CLIENT 语法通过(模板字面量里的反斜杠陷阱已按 :2311 注释约定规避)。dist/index.js含新端点。分支说明
分支直接堆在 #5325 的原提交
171417cd上(非 cherry-pick):先合 #5325 则本 PR diff 只剩这一层;两者一起合也干净。请按序合并。已知边界(v1)
.billion-context/packs/)的包只提示手动编辑,不提供写入端点(项目目录是信任门控区,见 [Security][pi] Gate project ACP config and packs on Pi project trust #2529)。补遗(按 #5328 验收标准复核,分支顶端两个补充提交)
rebase 到当前分支头后验证:typecheck clean;web-routing(9)+web-user-packs(1)+web-pack-picker(1)+chat-pack(4)+pack-install(6)=21/21 pass;build 绿。