Repository navigation
[PR] (ai: anthropic/claude-opus-4-6) bili pack install: Standard format for custom compressed prompt packs + one-command npm | (ai: anthropic/claude-opus-4-6) bili pack install:自定义压缩提示词包的标准格式 + npm 一条命令安装 - #5342
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.
…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
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.7485-pr.5342.a436542This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5342.tgz
npm install -g packageInstall instructions are refreshed on each push. |
This was referenced Nov 10, 2026
Closed
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 #5340
Refs #5319(pack 总需求)、#5331(网页端管理)、#5325(动态列表)
这是什么
pack 工作流的最后一块。之前别人想分享一个压缩提示词包,只能手动把 JSON 文件放进
~/.config/billion-context/packs/——既没有格式文档可查,也没有像样的分发方式。这个 PR 补上两件事:CONFIGURATION.md/zh-CN新增完整字段说明+示例——哪些字段会被 sanitize 器丢弃、section 值null= 保留默认文本、至少要有一个识别字段;bili-pack.json(内容就是 pack 对象)即"是一个可安装的 pack";然后bili pack install <名字>完事。新命令全套:
设计要点
npm install --prefix <tmp> <spec>,只从结果里读那一个文件。registry 鉴权、版本范围、scoped 包、git URL、本地.tgz全部按普通 npm 行为工作——不自己解析 tarball。isValidPackName+sanitizePackSurface+ 非空 surface 检查(把 web handler 的packSurfaceHasContent导出复用);坏 JSON、非法 name、空 surface 落盘前拒绝并给出明确报错。--force才替换;写盘走 temp-file+rename 原子范式。<configDir>/packs/,--project指向./.billion-context/packs/(与解析链一致)。Kernel Boundary
不涉及
kernel/**;只调用已导出的isValidPackName/sanitizePackSurface/listResolvedPacks。Config surface
无新配置字段、无新 env;纯新增 CLI 子命令与文档。
双模式推理
pack 文件每次 resolve 时现读,proxy/plugin 两条链路共用同一条解析链;本 PR 只是给这条链加了另一个写入方(CLI),行为一致。
验证
本分支堆叠在 #5325 → #5331 之上(复用了它们的导出函数)。请按序合并:#5325 → #5331 → 本 PR。前两个合并后本 PR diff 自动收缩为只剩这层改动。
已知边界