mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
移除 pi-extension-codex-fast-mode:
- 删除整个扩展目录;同步清理根 package.json 的 files / pi.extensions /
dependencies 条目、package-lock.json、tests/extension-load.test.ts 断言
与文档章节。
- pi-minimal-footer 的 Fast on 渲染是该扩展的唯一消费者。扩展移除后 accent
分支不再有生产者,collectFooterStatusItems 简化为直接返回非空状态字符串,
去掉 FooterStatusItem 与 accent 标志,避免留下死代码。
移除 500 次裁决后的后台分析体系:
- 删除 analysis-agent.ts(192 行)与 ledger.ts(296 行),以及对应的
auto-review-runtime / auto-review-ledger 测试。
- runtime.ts 由 177 行收敛到 85 行:安装选项缩为 { service, config };删除
handleAgentSettled 与 agent_settled 注册;保留 session_start / turn_start
(denial circuit breaker 属安全语义)/ session_shutdown。
- 删除 analysis 配置键:config、extension-config、config-schema、生成的
permissions.schema.json 与种子配置。
- 删除 reviewer 的 onDecision 回调(唯一消费者是 ledger)。
- 删除迁移机制 scripts/migrate-permission-policy.mjs、其测试与 update.sh 中
46 行 migrate_permission_policy 接线。种子部署保持“目标缺失才写入”,已存在
的 policy.jsonc 永不被覆盖。
AutoReview 模型改为纯配置驱动:
- 删除 DEFAULT_PROVIDER / DEFAULT_MODEL 常量与 findCodexTemplate 合成逻辑;
model.ts 由 65 行收敛到 48 行。
- provider / model 任一缺失时返回新增失败类别 model-unconfigured 并 defer 到
人工审批;provider 未注册或模型未发布同样 defer。
- reasoning 不再有默认常量,完全由配置决定。
- session_start 在 auto-review 已列入 authorizerChain 且 provider/model 未配齐
时 ui.notify 提示一次,避免不使用 AutoReview 的用户被打扰。
- 种子 autoReview 只保留 enabled,provider/model/reasoning 由用户按本机实际
可用的模型填写。
破坏性变更:analysis 键已从 strictObject schema 删除,任何仍带该键的
policy.jsonc 会使整份配置被拒(fail-closed 到全 ask)。这是刻意的变更,已由
config-loader 测试固定,防止将来无声放宽。
测试:
- 新增 auto-review-model.test.ts(7 例),覆盖此前完全缺失的模型解析:真实
命中、未配置、provider 未知、模型未发布,以及不再合成替代模型。
- 重写 auto-review-runtime.test.ts(6 例):authorizer 注册、未配置时提示
一次、已配置 / disabled / 无 UI / 不在 chain 时静默。
- config-loader.test.ts 新增 2 例:带 analysis 的旧配置被拒且 fail-closed、
autoReview 逐字段合并。
- composition-root.test.ts 的 EXPECTED_HANDLERS 移除 agent_settled。
文档:AGENTS.md、README.md、pi-permission-system 的 README / CHANGELOG /
configuration.md / architecture.md / auto-review UPSTREAM.md。
验证:pi-permission-system 的 typecheck、2577 个测试与 build 全部通过;根 50
个测试通过;schema 重新生成无漂移;新种子通过 schema 校验;5 个脚本 sh -n
通过;git diff --check 无空白问题。未安装 shellcheck;未执行真实 pi install /
update(属外部写操作)。
299 lines
16 KiB
JSON
299 lines
16 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://raw.githubusercontent.com/gotgenes/pi-packages/main/packages/pi-permission-system/schemas/permissions.schema.json",
|
|
"type": "object",
|
|
"properties": {
|
|
"$schema": {
|
|
"description": "JSON Schema URI for editor autocomplete and validation.",
|
|
"type": "string"
|
|
},
|
|
"debugLog": {
|
|
"description": "Write verbose permission-system diagnostics to the extension logs directory.",
|
|
"markdownDescription": "Write verbose permission-system diagnostics to `logs/pi-permission-system-debug.jsonl` under the extension config directory.",
|
|
"default": false,
|
|
"type": "boolean"
|
|
},
|
|
"permissionReviewLog": {
|
|
"description": "Write permission request and decision audit events to the extension logs directory.",
|
|
"markdownDescription": "Write permission request and decision audit events to `logs/pi-permission-system-permission-review.jsonl` under the extension config directory.",
|
|
"default": true,
|
|
"type": "boolean"
|
|
},
|
|
"yoloMode": {
|
|
"description": "Auto-approve ask-state permission checks, including subagent approval forwarding.",
|
|
"markdownDescription": "Auto-approve `ask`-state permission checks, including subagent approval forwarding.\n\n⚠️ **Use with caution** — this disables all interactive confirmation prompts.",
|
|
"default": false,
|
|
"type": "boolean"
|
|
},
|
|
"doublePressToConfirm": {
|
|
"description": "Require a confirming second press of a decision hotkey in the inline permission dialog. Applies to TUI sessions only.",
|
|
"markdownDescription": "Require a confirming second press of a decision hotkey (`y`/`s`/`n`/`r`) in the inline permission dialog before it commits — the first press arms the action and shows a `Press y again to approve.` hint.\n\nApplies to interactive **TUI** sessions only; the non-TUI (RPC/frontend) prompt keeps its single-select flow. Set to `false` to commit decisions on the first hotkey press.",
|
|
"default": true,
|
|
"type": "boolean"
|
|
},
|
|
"forwardingTimeoutMs": {
|
|
"description": "How long a subagent waits for the parent session to answer a forwarded permission request, in milliseconds. Omit to use the default (600000, ten minutes).",
|
|
"markdownDescription": "How long a subagent waits for the parent session to answer a forwarded permission request, in milliseconds.\n\nOmit to use the default (`600000`, ten minutes). A child whose in-process parent is not draining its inbox at all gives up in a couple of seconds regardless of this value, so lower it only to bound how long you are willing to leave an *unanswered* prompt pending.",
|
|
"default": 600000,
|
|
"type": "integer",
|
|
"minimum": 1,
|
|
"maximum": 9007199254740991
|
|
},
|
|
"promptMaxRows": {
|
|
"description": "Maximum rows a permission prompt renders before eliding its evidence. Omit to use the default (24).",
|
|
"markdownDescription": "Maximum rows a permission prompt renders before eliding its evidence.\n\nOmit to use the default (24). The request's own facts — the requesting agent, the tool, the matched rule, the decision-relevant value — are never elided by this budget; what gives way is the supporting evidence, and `Ctrl+O` expands the prompt to the complete request.",
|
|
"default": 24,
|
|
"type": "integer",
|
|
"minimum": 1,
|
|
"maximum": 9007199254740991
|
|
},
|
|
"promptFieldMaxWidth": {
|
|
"description": "Maximum characters of any one field shown in a permission prompt. Omit to use the default (400).",
|
|
"markdownDescription": "Maximum characters of any one field shown in a permission prompt.\n\nOmit to use the default (400). This is what bounds a single pathological field — a long here-string command, say — that would otherwise fill the prompt through wrapping. A shortened field is marked with an ellipsis, and `Ctrl+O` shows it in full.",
|
|
"default": 400,
|
|
"type": "integer",
|
|
"minimum": 1,
|
|
"maximum": 9007199254740991
|
|
},
|
|
"reviewLogFieldMaxWidth": {
|
|
"description": "Maximum characters of any one value written to the permission review log. Omit to use the default (1000).",
|
|
"markdownDescription": "Maximum characters of any one value written to the permission review log.\n\nOmit to use the default (1000). Every string the review log writes is narrowed to this width and marked with an ellipsis, so the log's growth is a decision you make rather than a side effect of how long a command happened to be. Raise it to keep longer values — a bash command exceeding the width is stored shortened.\n\nThis is a length bound, not redaction: it never inspects a value to decide what to hide. Key-name masking is unchanged and applies independently.",
|
|
"default": 1000,
|
|
"type": "integer",
|
|
"minimum": 1,
|
|
"maximum": 9007199254740991
|
|
},
|
|
"toolInputPreviewMaxLength": {
|
|
"deprecated": true,
|
|
"description": "Deprecated and ignored. Superseded by promptMaxRows and promptFieldMaxWidth, which bound the whole prompt rather than one preview. Still accepted so an existing config is not rejected; remove it.",
|
|
"markdownDescription": "**Deprecated and ignored.** Superseded by `promptMaxRows` and `promptFieldMaxWidth`, which bound the whole permission prompt rather than one preview inside it.\n\nStill accepted so an existing config is not rejected fail-closed, but the value no longer takes effect. Remove it.",
|
|
"type": "integer",
|
|
"minimum": 1,
|
|
"maximum": 9007199254740991
|
|
},
|
|
"toolTextSummaryMaxLength": {
|
|
"deprecated": true,
|
|
"description": "Deprecated and ignored. Superseded by promptMaxRows and promptFieldMaxWidth, which bound the whole prompt rather than one summary. Still accepted so an existing config is not rejected; remove it.",
|
|
"markdownDescription": "**Deprecated and ignored.** Superseded by `promptMaxRows` and `promptFieldMaxWidth`, which bound the whole permission prompt rather than one summary inside it.\n\nStill accepted so an existing config is not rejected fail-closed, but the value no longer takes effect. Remove it.",
|
|
"type": "integer",
|
|
"minimum": 1,
|
|
"maximum": 9007199254740991
|
|
},
|
|
"authorizerChain": {
|
|
"description": "Ordered names of registered live-authority chain links to consult before the terminal authorizer. Config order (not registration order) fixes the chain order; an unregistered name is skipped fail-safe (more prompting, never less); a link decides nothing until it is named here.",
|
|
"markdownDescription": "Ordered names of registered **live-authority chain links** (for example AutoReview) to consult before the terminal human authorizer. A named link may approve or deny any ordinary-policy `ask`, including `path`; `defer` advances to the next link or the human terminal. Defaults to an empty list.",
|
|
"default": [],
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string",
|
|
"minLength": 1
|
|
}
|
|
},
|
|
"permission": {
|
|
"type": "object",
|
|
"propertyNames": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"description": "A surface name or the universal fallback key '*'."
|
|
},
|
|
"additionalProperties": {
|
|
"anyOf": [
|
|
{
|
|
"$ref": "#/$defs/permissionState"
|
|
},
|
|
{
|
|
"$ref": "#/$defs/permissionMap"
|
|
}
|
|
]
|
|
},
|
|
"description": "Flat permission policy. Each key is a surface name; values are a PermissionState string (catch-all) or a pattern→action map.",
|
|
"markdownDescription": "Flat permission policy.\n\nEach top-level key is a surface name:\n- `\"*\"` — universal fallback\n- Tool names (`read`, `write`, `bash`, `mcp`, `skill`, `path`, etc.)\n\nA string value is shorthand for `{ \"*\": action }`. An object maps wildcard patterns to actions, and the most specific matching pattern wins.\n\nFor built-in file tools, patterns match `input.path`. The cross-cutting `path` surface checks path-bearing tools and bash path tokens.\n\n**Merge order (lowest → highest precedence):** global → per-agent frontmatter → project-agent frontmatter.",
|
|
"examples": [
|
|
{
|
|
"*": "ask",
|
|
"path": {
|
|
"*": "allow",
|
|
"*.env": "deny",
|
|
"*.env.*": "deny",
|
|
"*.env.example": "allow"
|
|
},
|
|
"read": "allow",
|
|
"write": "deny",
|
|
"edit": "deny",
|
|
"bash": {
|
|
"*": "ask",
|
|
"git *": "ask",
|
|
"git status": "allow",
|
|
"git diff": "allow"
|
|
},
|
|
"mcp": {
|
|
"*": "ask",
|
|
"mcp_status": "allow",
|
|
"exa:*": "allow"
|
|
},
|
|
"skill": {
|
|
"*": "ask",
|
|
"librarian": "allow"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"autoReview": {
|
|
"description": "Built-in model-assisted reviewer used for static-policy review decisions.",
|
|
"type": "object",
|
|
"properties": {
|
|
"enabled": {
|
|
"type": "boolean"
|
|
},
|
|
"provider": {
|
|
"type": "string",
|
|
"minLength": 1
|
|
},
|
|
"model": {
|
|
"type": "string",
|
|
"minLength": 1
|
|
},
|
|
"reasoning": {
|
|
"type": "string",
|
|
"enum": [
|
|
"off",
|
|
"minimal",
|
|
"low",
|
|
"medium",
|
|
"high",
|
|
"xhigh",
|
|
"max"
|
|
]
|
|
},
|
|
"timeoutMs": {
|
|
"type": "integer",
|
|
"exclusiveMinimum": 0,
|
|
"maximum": 300000
|
|
},
|
|
"includeBaselinePolicy": {
|
|
"type": "boolean"
|
|
},
|
|
"additionalPolicy": {
|
|
"type": "string",
|
|
"minLength": 1
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"shellTools": {
|
|
"type": "object",
|
|
"propertyNames": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"description": "A non-bash tool name that carries shell semantics."
|
|
},
|
|
"additionalProperties": {
|
|
"type": "object",
|
|
"properties": {
|
|
"commandArgument": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"description": "The name of the tool's input argument holding the shell command string (e.g. 'cmd')."
|
|
},
|
|
"workdirArgument": {
|
|
"description": "Optional name of the tool's input argument holding the working directory (e.g. 'workdir').",
|
|
"type": "string",
|
|
"minLength": 1
|
|
},
|
|
"decisionFloor": {
|
|
"description": "Require every invocation of this shell alias to be reviewed at least as an ask; deny remains deny.",
|
|
"markdownDescription": "Sets the minimum review decision for this alias. `allow` results from Bash policy are raised to `ask`, while existing `ask` and `deny` results are preserved. Only `\"ask\"` is accepted so a project override cannot weaken a global floor.",
|
|
"type": "string",
|
|
"const": "ask"
|
|
}
|
|
},
|
|
"required": [
|
|
"commandArgument"
|
|
],
|
|
"additionalProperties": false,
|
|
"description": "Maps one shell-aliased tool to the input arguments holding its command and optional working directory, plus an optional ask decision floor."
|
|
},
|
|
"description": "Maps non-bash tool names that carry shell semantics to the input arguments holding their command and working directory.",
|
|
"markdownDescription": "Records which non-`bash` tools carry shell semantics, mapping each tool name to the input argument holding its command (and optionally its working directory).\n\nUse this when an extension replaces the native `bash` tool under a different name — e.g. `@howaboua/pi-codex-conversion` registers `exec_command` with a `cmd` argument and an optional `workdir`. Recording the alias lets the permission system gate that tool through the same bash enforcement stack as native `bash` (command decomposition, wrapper flooring, path/external-directory token gates, and `bash:` rules).\n\nSet `decisionFloor` to `\"ask\"` when the wrapper crosses an additional trust boundary, such as SSH or container execution. Bash `allow` results are raised to `ask`; existing `ask` and `deny` results remain unchanged.\n\nExample:\n\n```json\n\"shellTools\": {\n \"exec_command\": { \"commandArgument\": \"cmd\", \"workdirArgument\": \"workdir\" },\n \"ssh_bash\": { \"commandArgument\": \"command\", \"decisionFloor\": \"ask\" }\n}\n```\n\n**Merge order:** merge each tool mapping by field across global → project. Project values can replace argument names, while a global `decisionFloor: \"ask\"` survives when the project entry omits it.",
|
|
"examples": [
|
|
{
|
|
"exec_command": {
|
|
"commandArgument": "cmd",
|
|
"workdirArgument": "workdir"
|
|
},
|
|
"ssh_bash": {
|
|
"commandArgument": "command",
|
|
"decisionFloor": "ask"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"additionalProperties": false,
|
|
"title": "PI Permission System Configuration",
|
|
"description": "Ordinary JSONC policy combining runtime knobs, AutoReview settings, and flat permission rules for pi-permission-system.",
|
|
"markdownDescription": "Global ordinary JSONC policy for [pi-permission-system](https://github.com/gotgenes/pi-packages/tree/main/packages/pi-permission-system).\n\nPlace at `~/.pi/agent/extensions/pi-permission-system/policy.jsonc`. Project-level policy files are not loaded. Global-only hard guards use the separate `hard-guards.jsonc` schema.",
|
|
"$defs": {
|
|
"permissionState": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string",
|
|
"const": "allow",
|
|
"description": "Permit the action silently with no user interaction."
|
|
},
|
|
{
|
|
"type": "string",
|
|
"const": "deny",
|
|
"description": "Block the action with an error message. The agent is told not to retry."
|
|
},
|
|
{
|
|
"type": "string",
|
|
"const": "ask",
|
|
"description": "Prompt the user for confirmation via the interactive UI before proceeding."
|
|
}
|
|
],
|
|
"description": "A permission decision: allow (permit silently), deny (block with error), or ask (prompt the user for confirmation)."
|
|
},
|
|
"permissionMap": {
|
|
"type": "object",
|
|
"propertyNames": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"description": "A non-empty pattern string. Use * for wildcard matching. Prefix with ~/ or $HOME/ for home-relative paths."
|
|
},
|
|
"additionalProperties": {
|
|
"anyOf": [
|
|
{
|
|
"$ref": "#/$defs/permissionState"
|
|
},
|
|
{
|
|
"$ref": "#/$defs/denyWithReason"
|
|
}
|
|
]
|
|
},
|
|
"description": "A map of wildcard patterns to permission states. The most specific matching pattern wins.",
|
|
"markdownDescription": "A map of wildcard patterns to permission states.\n\nUse `*` for wildcard matching. When several patterns match, the most specific pattern wins: exact patterns first, then more literal characters, fewer wildcards, and longer patterns. Declaration order is only the final tie-breaker, where the later rule wins.\n\nPattern keys support home directory expansion: `~/path` and `$HOME/path` expand at match time. The stored pattern is shown in logs and approval dialogs as written."
|
|
},
|
|
"denyWithReason": {
|
|
"type": "object",
|
|
"properties": {
|
|
"action": {
|
|
"type": "string",
|
|
"const": "deny",
|
|
"description": "The permission decision — must be \"deny\"."
|
|
},
|
|
"reason": {
|
|
"description": "Optional reason shown to the agent when this action is denied.",
|
|
"type": "string",
|
|
"maxLength": 500
|
|
}
|
|
},
|
|
"required": [
|
|
"action"
|
|
],
|
|
"additionalProperties": false,
|
|
"description": "Deny with an optional custom reason shown to the agent when the action is blocked."
|
|
}
|
|
}
|
|
}
|