Skip to content

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

fix(plugin-devkit): warn on every permission the matrix marks high

GalaxyXieyu5bd79c034bef
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 76a5df735..a50580a62 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -3164,7 +3164,7 @@ identify the platform validation still needed.
- **Specs linked**: `07-plugins/10-plugin-devex.md` §5–§6, `07-plugins/06-plugin-packaging.md`, ADR 0039
- **Acceptance**: G (local packaging round-trip)
- **Milestone**: Post-MVP
-- **Status**: Automated in part (`packages/plugin-devkit` vitest: scaffold→check→pack per template, store-method headers, every check rule); install step Documented
+- **Status**: Automated in part (`packages/plugin-devkit` vitest: scaffold→check→pack per template, store-method headers, every check rule, and a parity test that pins the `permission.high-risk` list to the permissions matrix's high rows); install step Documented
#### E2E-023: Plugin command in global search and executes
diff --git a/docs/spec/07-plugins/10-plugin-devex.md b/docs/spec/07-plugins/10-plugin-devex.md
index 98b11991a..189a7273f 100644
--- a/docs/spec/07-plugins/10-plugin-devex.md
+++ b/docs/spec/07-plugins/10-plugin-devex.md
@@ -114,7 +114,9 @@ See [15-plugin-center.md](15-plugin-center.md).
install will pass. It reports errors — a missing or unparseable `manifest.json`,
missing `main` / `ui.panel` / skill files, a skill path escaping the plugin
directory, an unknown permission, a symlink, more than 2000 files, more than
-50 MB — and warnings, which do not block: high-risk permissions, permissions
+50 MB — and warnings, which do not block: high-risk permissions (every
+permission [13-plugin-permissions-matrix.md](13-plugin-permissions-matrix.md)
+marks high; a devkit test keeps the two lists equal), permissions
declared but never used by the code, `contributes.skills` without
`agent.prompt.inject` (the skills would be inert), and an empty `contributes`.
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index f1348c06c..c3989870b 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -1411,7 +1411,7 @@ task-candidate E2E 从请求工作树运行,但使用主工作区已经准备
- **链接规格**:`07-plugins/10-plugin-devex.md` §5–§6、`07-plugins/06-plugin-packaging.md`、ADR 0039
- **承兑**:G(本地包装往返)
- **里程碑**:后 MVP
-- **状态**:部分自动化(`packages/plugin-devkit` vitest:脚手架→检查→按模板打包,存储方法标头,每个检查规则);安装步骤已记录
+- **状态**:部分自动化(`packages/plugin-devkit` vitest:脚手架→检查→按模板打包,存储方法标头,每个检查规则,以及把 `permission.high-risk` 列表与权限矩阵 high 行对齐的一致性测试);安装步骤已记录
#### E2E-023:全局搜索中的插件命令并执行
diff --git a/docs/zh-CN/spec/07-plugins/10-plugin-devex.md b/docs/zh-CN/spec/07-plugins/10-plugin-devex.md
index 4266da3ee..5b6648d8f 100644
--- a/docs/zh-CN/spec/07-plugins/10-plugin-devex.md
+++ b/docs/zh-CN/spec/07-plugins/10-plugin-devex.md
@@ -108,7 +108,8 @@ pnpm pi-plugin publish .
安装会通过。它报告错误 - 丢失或无法解析的 `manifest.json`,
缺少 `main` / `ui.panel` / 技能文件,转义插件的技能路径
目录,未知权限,符号链接,超过 2000 个文件,超过
-50 MB — 以及警告,不会阻止:高风险权限、权限
+50 MB — 以及警告,不会阻止:高风险权限([13-plugin-permissions-matrix.md](13-plugin-permissions-matrix.md)
+中标为 high 的全部权限,devkit 测试保证两份列表一致)、权限
声明但从未被代码使用,`contributes.skills` 不带
`agent.prompt.inject`(技能将是惰性的),以及空的 `contributes`。
diff --git a/packages/plugin-devkit/src/check.test.ts b/packages/plugin-devkit/src/check.test.ts
index 14184ecbf..1c14cb365 100644
--- a/packages/plugin-devkit/src/check.test.ts
+++ b/packages/plugin-devkit/src/check.test.ts
@@ -1,6 +1,7 @@
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
+import { fileURLToPath } from "node:url";
import { afterEach, describe, expect, it } from "vitest";
import { check, HIGH_RISK_PERMISSIONS } from "./check.js";
import { scaffold } from "./templates.js";
@@ -114,6 +115,29 @@ describe("check", () => {
}
});
+ it("warns on exactly the permissions the permissions matrix marks high (#1463)", async () => {
+ const matrix = await readFile(
+ fileURLToPath(
+ new URL("../../../docs/spec/07-plugins/13-plugin-permissions-matrix.md", import.meta.url),
+ ),
+ "utf8",
+ );
+ const high = [...matrix.matchAll(/^\| `([A-Za-z0-9.]+)` \| high \|/gm)].map((m) => m[1]);
+ expect(high).toContain("renderer.extension");
+ expect([...HIGH_RISK_PERMISSIONS].sort()).toEqual([...new Set(high)].sort());
+ });
+
+ it("names grants such as desktop.control and session.read in the high-risk warning", async () => {
+ const dir = join(await tempDir(), "high-risk-grants");
+ await scaffold({ dir, template: "panel-basic" });
+ await editManifest(dir, (m) => {
+ m.permissions = [...(m.permissions ?? []), "desktop.control", "session.read"];
+ });
+ const highRisk = (await check(dir)).warnings.find((w) => w.code === "permission.high-risk");
+ expect(highRisk?.message).toContain("desktop.control");
+ expect(highRisk?.message).toContain("session.read");
+ });
+
it("warns when background capability permissions are declared but never called", async () => {
const dir = join(await tempDir(), "background-apis");
await scaffold({ dir, template: "panel-basic" });
diff --git a/packages/plugin-devkit/src/check.ts b/packages/plugin-devkit/src/check.ts
index eac576314..708689004 100644
--- a/packages/plugin-devkit/src/check.ts
+++ b/packages/plugin-devkit/src/check.ts
@@ -20,9 +20,9 @@ import {
} from "./walk.js";
/**
- * Permissions the permission dialog surfaces as high risk. Kept in sync with
- * `PERMISSION_RISK` in apps/desktop/src/features/plugins/model.ts, which is the
- * copy the install dialog actually renders.
+ * Permissions the permissions matrix
+ * (docs/spec/07-plugins/13-plugin-permissions-matrix.md) marks high risk; a
+ * test keeps this list equal to the matrix's high rows.
*/
export const HIGH_RISK_PERMISSIONS = [
"net.fetch",
@@ -30,8 +30,22 @@ export const HIGH_RISK_PERMISSIONS = [
"net.websocket",
"fs.write",
"fs.delete",
+ "fs.write.workspace",
+ "fs.delete.workspace",
"agent.prompt.inject",
"agent.tool.register",
+ "agent.extension",
+ "agent.complete",
+ "renderer.extension",
+ "provider.register",
+ "provider.oauth",
+ "desktop.control",
+ "project.create",
+ "session.read",
+ "session.import",
+ "session.delete.own",
+ "mcp.server.local",
+ "mcp.server.remote",
"browser.cdp",
"audio.capture.background",
"speech.adapter.register",