Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(config-sync): remove the instruction-file size cap

vastsacb4183e12812
diff --git a/crates/host-core/src/config_sync/domains.rs b/crates/host-core/src/config_sync/domains.rs
index ca6315041..fd7fd0d32 100644
--- a/crates/host-core/src/config_sync/domains.rs
+++ b/crates/host-core/src/config_sync/domains.rs
@@ -28,7 +28,6 @@ pub const DOMAIN_PROJECTS: &str = "projects";
pub const DOMAIN_PLUGINS: &str = "plugins";
pub const DOMAIN_AUTOMATION: &str = "automation";
pub const DOMAIN_MEMORY: &str = "memory";
-pub const MAX_INSTRUCTION_BYTES: usize = 32 * 1024;
pub(crate) const PORTABLE_APPLICATION_FIELDS: &[&str] = &[
"theme",
@@ -738,4 +737,42 @@ mod tests {
let mapped = capture_projects(&mut state, &overrides).unwrap();
assert_eq!(mapped[0].payload["logicalId"], "project:from-other-device");
}
+
+ #[test]
+ fn captures_project_instruction_files_beyond_the_former_size_cap() {
+ let data_dir = tempfile::tempdir().unwrap();
+ let project = data_dir.path().join("project");
+ std::fs::create_dir_all(&project).unwrap();
+ let content = "policy line\n".repeat(4000);
+ assert!(content.len() > 32 * 1024);
+ std::fs::write(project.join("AGENTS.md"), &content).unwrap();
+
+ let mut state = AppState::open(data_dir.path()).unwrap();
+ state
+ .db
+ .ensure_project(&project.to_string_lossy(), false)
+ .unwrap();
+ let entities =
+ capture_instructions(&mut state, &ProjectIdentityOverrides::default()).unwrap();
+ let project_entity = entities
+ .iter()
+ .find(|entity| entity.payload["scope"] == "project")
+ .expect("project instruction entity");
+ assert_eq!(
+ project_entity.payload["content"].as_str(),
+ Some(content.as_str())
+ );
+ }
+
+ #[test]
+ fn writes_imported_instruction_files_beyond_the_former_size_cap() {
+ let data_dir = tempfile::tempdir().unwrap();
+ let path = data_dir.path().join("AGENTS.md");
+ let content = "imported line\n".repeat(4000);
+ assert!(content.len() > 32 * 1024);
+
+ write_instruction_file(&path, &content).unwrap();
+
+ assert_eq!(std::fs::read_to_string(&path).unwrap(), content);
+ }
}
diff --git a/crates/host-core/src/config_sync/domains_capture.rs b/crates/host-core/src/config_sync/domains_capture.rs
index 83dacc8cc..2bff4859e 100644
--- a/crates/host-core/src/config_sync/domains_capture.rs
+++ b/crates/host-core/src/config_sync/domains_capture.rs
@@ -516,11 +516,6 @@ fn read_instruction_file(path: &Path) -> Result<Option<String>> {
return Ok(None);
}
let bytes = fs::read(path)?;
- if bytes.len() > MAX_INSTRUCTION_BYTES {
- return Err(anyhow::anyhow!(
- "CONFIG_SYNC_LIMIT_EXCEEDED: instruction file is too large"
- ));
- }
let content = String::from_utf8(bytes)
.map_err(|_| anyhow::anyhow!("CONFIG_SYNC_INVALID: instruction file is not UTF-8"))?;
if content.trim().is_empty() {
@@ -535,11 +530,6 @@ pub(crate) fn global_instruction_path_for_sync() -> Result<PathBuf> {
}
pub(crate) fn write_instruction_file(path: &Path, content: &str) -> Result<()> {
- if content.len() > MAX_INSTRUCTION_BYTES {
- return Err(anyhow::anyhow!(
- "CONFIG_SYNC_LIMIT_EXCEEDED: instruction file is too large"
- ));
- }
if fs::symlink_metadata(path)
.map(|metadata| metadata.file_type().is_symlink())
.unwrap_or(false)
diff --git a/docs/spec/03-runtime/22-config-sync.md b/docs/spec/03-runtime/22-config-sync.md
index aa454f319..318b13ba6 100644
--- a/docs/spec/03-runtime/22-config-sync.md
+++ b/docs/spec/03-runtime/22-config-sync.md
@@ -41,6 +41,9 @@ The instruction adapter reads only the fixed global `~/.pi/agent/AGENTS.md`
and each registered project's root `AGENTS.md`; it does not scan nested
repositories or arbitrary files. Imported instruction files are written only
after their scope is explicitly selected, mapped where required, and approved.
+Instruction files carry no instruction-specific byte cap; their content is
+bounded only by the shared portable-entity payload bound Host checks when it
+uploads a revision and when it validates a remote one.
Directory-shaped skills carry bounded sibling resources as authenticated
objects. Package paths, symlinks, collisions, file counts, and total size are
validated by Host before approved resources are written: at most 256 resources
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index a8775118c..9d2dbaf4a 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -38,6 +38,7 @@ This log freezes previously open questions into concrete decisions.
| D641 | Custom endpoint API style precedence | **A custom endpoint uses the saved provider-row `apiStyle` ahead of a model catalog's adapter API. Named and OAuth providers can continue to use a model-level wire API pin where their published configuration requires a different transport. This keeps a user's explicit endpoint choice stable without removing model-specific routing such as OpenCode Go Responses models. No persisted format or protocol change. See E2E-005E and issue #1313.** | A publisher's adapter default must not silently redirect a custom gateway whose user-selected API format is different. |
| D642 | Cloud sync is a public Experimental destination *(amended by D643)* | **Remove the developer-mode and packaged-build gates from the Settings `sync` destination: its rail row, page, and settings-search hits exist for every user in every build, and a saved `sync` tab no longer falls back to General. Remote Hosts keeps both gates and its own badge. The destination keeps its Experimental badge on the rail row and page title; sync behavior, protocol, host schema, and persisted data are unchanged. See `04-ux/06-settings-ia.md` and E2E-CONFIG-SYNC-webdav-portable-configuration.** | Encrypted WebDAV backup is the app's only multi-device configuration path, and a developer-mode gate left it undiscoverable for the users who need it. |
| D643 | Cloud sync ships without an Experimental badge | **Amend D642: the Settings `sync` destination drops `experimentalBadgeKey`, and `settings.configSync.experimental` is removed from every bundled locale. Cloud sync stays available to every user in every build. Remote Hosts keeps its own badge and both gates. Sync behavior, protocol, host schema, and persisted data are unchanged. See `04-ux/06-settings-ia.md` and E2E-CONFIG-SYNC-webdav-portable-configuration.** | Cloud sync is the app's shipped multi-device path, so an Experimental label no longer described it and only made the destination look unfinished. |
+| D644 | Portable instruction files have no size cap | **Remove the 32 KiB per-file cap Host enforced on portable instruction files. Global and project instruction content is bounded only by the same portable-entity payload bound every other domain already has, checked when a revision is uploaded and when a remote one is validated. UTF-8 validation, symlink rejection, scope selection, mapping, and approval rules are unchanged. See `03-runtime/22-config-sync.md` §2.** | A 33 KiB project `AGENTS.md` failed the entire capture with `CONFIG_SYNC_LIMIT_EXCEEDED: instruction file is too large`, which the Settings page could only show as a generic backup-size error. |
| D450 | Signed macOS GitHub Releases | **Amend D078 / ADR 0022: GitHub tag releases Developer ID-sign, notarize (`notarytool` via electron-builder 26), staple, and Gatekeeper-verify macOS DMG/ZIP before upload, using identity `Developer ID Application: XingYu Liu (DUV63RKYTW)` / team `DUV63RKYTW` from Actions secrets (`CSC_LINK`, `CSC_KEY_PASSWORD`, `APPLE_ID`, `APPLE_APP_SPECIFIC_PASSWORD`, `APPLE_TEAM_ID`). Missing secrets fail the job. Local unsigned packaging without a certificate remains. `workflow_dispatch` may set `sign_macos: false` only for unsigned debug artifacts. Packaged macOS uses in-app `electron-updater` (ZIP + merged `latest-mac.yml`); Linux deb/rpm and Windows portable ZIP stay notify-and-link. No afterPack/afterSign adhoc codesign (ADR 0278).** | Production DMGs must open without a Gatekeeper warning, and signed macOS installs can download and restart into a new tag. See ADR 0289, E2E-196c, E2E-067A. |
## B. Secondary implementation defaults
@@ -7437,3 +7438,20 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
`apps/desktop/test/settings-developer-only-destinations.test.mjs` and
`apps/desktop/test/config-sync-settings.test.mjs`, plus the Cloud sync probe
in `pnpm test:e2e:settings-scroll`.
+
+## 2026-10-04 — Instruction files sync without an instruction-specific byte cap (D644)
+
+- D644 removes the 32 KiB per-file cap Host enforced on portable instruction
+ files. A project `AGENTS.md` larger than that cap failed the whole capture
+ with `CONFIG_SYNC_LIMIT_EXCEEDED: instruction file is too large`, which the
+ settings page could only report as a generic backup-size error.
+- Instruction content is now bounded only by the shared portable-entity payload
+ bound Host checks when it uploads a revision and when it validates a remote
+ one. UTF-8 validation, symlink rejection, scope selection, mapping, and
+ approval rules are unchanged, and the agent-runtime prompt chain keeps its
+ own read-side budget.
+- Covered by
+ `config_sync::domains::tests::captures_project_instruction_files_beyond_the_former_size_cap`
+ and
+ `config_sync::domains::tests::writes_imported_instruction_files_beyond_the_former_size_cap`
+ in `crates/host-core/src/config_sync/domains.rs`.
diff --git a/docs/zh-CN/spec/03-runtime/22-config-sync.md b/docs/zh-CN/spec/03-runtime/22-config-sync.md
index 4f9b9d51d..efc565aaf 100644
--- a/docs/zh-CN/spec/03-runtime/22-config-sync.md
+++ b/docs/zh-CN/spec/03-runtime/22-config-sync.md
@@ -23,6 +23,7 @@ Host-core 持有 vault key、WebDAV 传输、修订状态、合并基线、待
当前适配器集合覆盖应用偏好、用户所有的 providers、MCP 定义、用户 skills、全局 subagents、由应用管理的全局/项目指令与项目、插件安装意图、定时自动化任务以及可选的项目记忆。凭据默认需要明确选择。只有选中凭据类别时才会包含 provider API key 和 MCP 环境变量/headers;OAuth access/refresh token 与 cookies 永远不会导出。
指令适配器只读取固定的全局 `~/.pi/agent/AGENTS.md` 和每个已注册项目根目录的 `AGENTS.md`;不会扫描嵌套仓库或任意文件。导入的指令文件只有在明确选择其作用域、完成必要映射并获得审批后才会写入。
+指令文件没有单独的字节上限;其内容只受 Host 在上传与远程校验时统一的便携实体负载上限约束。
目录形态的 skills 会将有界的同级资源作为已认证对象携带。Host 会校验 package path、symlink、冲突、文件数量和总大小后才写入已审批的资源:每个 package 最多 256 个资源、单个资源 2 MiB、整个 package 16 MiB;技能文档本身仍保持 128 KiB 上限,因为它可能进入 prompt。脚本按字节存储,导入时绝不执行。
项目和 workspace 绑定使用不透明的逻辑标识符表示。Host-core 为每个已注册的独立项目分配持久逻辑身份;项目组根目录的身份由组身份和有序根位置派生。设备映射把接收的逻辑 ID 覆盖到本地文件夹,因此不同绝对路径不会产生重复实体。
diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.md
index 00e225231..4ccafb528 100644
--- a/docs/zh-CN/spec/08-meta/decisions-log.md
+++ b/docs/zh-CN/spec/08-meta/decisions-log.md
@@ -41,6 +41,7 @@
| D641 | 自定义端点 API 格式优先级 | **自定义端点始终优先使用 provider 行上保存的 `apiStyle`,再考虑模型目录适配器 API。对于具名与 OAuth provider,如果已发布配置要求不同传输,仍可沿用模型级 wire API 固定项。这可确保用户为自定义 endpoint 选择的格式不会被静默覆盖,同时保留 OpenCode Go Responses 模型等特定路由。不改变持久化格式或协议。见 E2E-005E 与 issue #1313。** | 发布方的适配器默认值不应把请求从用户已选择的自定义网关格式静默重定向。 |
| D642 | 云同步是对所有用户开放的实验性目的地 *(由 D643 修订)* | **移除设置中 `sync` 目的地的开发者模式与打包构建门控:其导轨行、页面和设置搜索命中在任何构建中对所有用户存在,已保存的 `sync` 标签页也不再回落到常规。远程主机保留这两道门控和它自己的徽章。该目的地继续在导轨行与页面标题上保留实验性徽章;同步行为、协议、Host schema 与持久化数据均不变。见 `04-ux/06-settings-ia.md` 与 E2E-CONFIG-SYNC-webdav-portable-configuration。** | 加密 WebDAV 备份是应用唯一的多设备配置路径,而开发者模式门控让需要它的用户无法发现该功能。 |
| D643 | 云同步不再带实验性徽章 | **修订 D642:设置中的 `sync` 目的地不再有 `experimentalBadgeKey`,各内置语言包中的 `settings.configSync.experimental` 键也已删除。云同步在任何构建中对所有用户保持可用。远程主机保留自己的徽章和两道门控。同步行为、协议、Host schema 与持久化数据均不变。见 `04-ux/06-settings-ia.md` 与 E2E-CONFIG-SYNC-webdav-portable-configuration。** | 云同步是应用已发布的多设备路径,实验性标签已不再描述它,只会让该目的地看起来尚未完成。 |
+| D644 | 便携指令文件没有体积上限 | **移除 Host 对便携指令文件施加的 32 KiB 单文件上限。全局与项目指令内容只受其他域同样拥有的便携实体负载上限约束,并在上传修订与校验远端修订时检查。UTF-8 校验、symlink 拒绝、作用域选择、映射与审批规则均不变。见 `03-runtime/22-config-sync.md` §2。** | 一个 33 KiB 的项目 `AGENTS.md` 会让整次采集以 `CONFIG_SYNC_LIMIT_EXCEEDED: instruction file is too large` 失败,而设置页只能把它显示为泛化的备份体积错误。 |
| D450 | 签名的 macOS GitHub Release | **修订 D078 / ADR 0022:GitHub tag 发布使用身份 `Developer ID Application: XingYu Liu (DUV63RKYTW)` / 团队 `DUV63RKYTW`,通过 Actions 密钥(`CSC_LINK`、`CSC_KEY_PASSWORD`、`APPLE_ID`、`APPLE_APP_SPECIFIC_PASSWORD`、`APPLE_TEAM_ID`)对 macOS DMG/ZIP 做 Developer ID 签名、`notarytool` 公证、装订和 Gatekeeper 校验;缺少密钥则失败。无证书的本地未签名打包仍可用。`workflow_dispatch` 仅可把 `sign_macos: false` 用于未签名调试产物。打包的 macOS 走应用内 `electron-updater`(ZIP + 合并后的 `latest-mac.yml`);Linux deb/rpm 与 Windows 便携版 ZIP 仍为通知并打开发布页。禁止 afterPack/afterSign adhoc 签名(ADR 0278)。** | 正式 DMG 应无需 Gatekeeper 警告即可打开,已签名 macOS 安装可下载并重启到新 tag。见 ADR 0289、E2E-196c、E2E-067A。 |
## B. 辅助实现默认值
@@ -5236,3 +5237,16 @@ Markdown 源码,不是 `text/html` 负载;对禁用行内 HTML 的外部编
- 由 `apps/desktop/test/settings-developer-only-destinations.test.mjs`、
`apps/desktop/test/config-sync-settings.test.mjs` 中的徽章断言,以及
`pnpm test:e2e:settings-scroll` 的云同步探针覆盖。
+
+## 2026-10-04 —— 指令文件同步不再有单独的字节上限(D644)
+
+- D644 移除 Host 对便携指令文件施加的 32 KiB 单文件上限。超过该上限的项目
+ `AGENTS.md` 会让整次采集以 `CONFIG_SYNC_LIMIT_EXCEEDED: instruction file is too
+ large` 失败,而设置页只能把它显示为泛化的备份体积错误。
+- 指令内容现在只受其他域同样拥有的便携实体负载上限约束,Host 在上传修订与校验远端
+ 修订时检查该上限。UTF-8 校验、symlink 拒绝、作用域选择、映射与审批规则均不变;
+ agent-runtime 的 prompt 指令链保留自己的读取侧预算。
+- 由 `crates/host-core/src/config_sync/domains.rs` 中的
+ `config_sync::domains::tests::captures_project_instruction_files_beyond_the_former_size_cap`
+ 与 `config_sync::domains::tests::writes_imported_instruction_files_beyond_the_former_size_cap`
+ 覆盖。