Skip to content

Commit c52ea64

Browse files
author
SqlRush
committed
Load remote managed policy settings
1 parent 6c74b0a commit c52ea64

5 files changed

Lines changed: 247 additions & 16 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ M7 补充:prompt history `LogEntry` 读取现在接受 `sessionID`/`session`/`
731731
本轮补充:`cmd/claude --help` 现在沿用 Go flag usage 输出并成功退出;`cmd/claude --cwd` 现在会设置 bootstrap working directory,影响 scaffold 输出、project settings、tool cwd 和 transcript path;`cmd/claude --print/-p` 现在接入真实 `conversation.Runner.RunTurn` 单轮 headless 路径,可从参数或 stdin 读取 prompt,读取 `ANTHROPIC_API_KEY`/`ANTHROPIC_BASE_URL`/`ANTHROPIC_MODEL`/`CLAUDE_MODEL`/settings model,解析模型别名,装配 builtin tools、settings-derived permission engine、settings-derived MCP config,并把最终 assistant text 写到 stdout;`--mcp-config`/`--mcpConfig` 现在会把指定 JSON 文件中的 `mcpServers` 合入 headless MCP local settings;`--input-format`/`--inputFormat` text/json/stream-json 现在有基础输入解析,支持 JSON prompt/user message 和 NDJSON user event;`--max-turns`/`--maxTurns` 现在会限制 headless tool-use loop 轮数,`--max-tokens`/`--maxTokens` 和 `--max-turns`/`--maxTurns` 都会拒绝负值;`--output-format`/`--outputFormat` json 现在会输出基础 result envelope,`stream-json` 会先输出基础 `system/init` 事件,再输出 NDJSON event stream 并以 result 行收尾,包含 result text、session id、assistant message、stop reason、model、usage 和 tool results;headless setup/resume/RunTurn 错误现在会在 JSON 模式输出 `subtype:error` result,在 stream-json 模式输出 `type:error` event;`--permission-mode`/`--permissionMode`、`--dangerously-skip-permissions`/`--dangerouslySkipPermissions`、`--system-prompt`/`--systemPrompt` 和 `--append-system-prompt`/`--appendSystemPrompt` 现在也有 CLI 接线或 camelCase alias;`--stream --output-format stream-json` 现在还会透出 raw Anthropic streaming events,包括 text delta;headless `--resume <session-id-or-jsonl>` 和 `--continue` 现在会加载当前项目 transcript chain 作为 history,并把新回合追加回同一个 transcript;`--allowedTools`/`--allowed-tools` 和 `--disallowedTools`/`--disallowed-tools` 现在会作为 CLI permission rules 合入 headless permission engine;`--add-dir`/`--addDir` 现在会作为 CLI additional working directory 合入 headless permission context。
732732
本轮补充:settings 文件读取现在有 path-keyed cache,按 size/mode/mtime 指纹复用内容并提供 cache reset;新增 settings change detector,可对 settings 文件快照区分 created/modified/deleted,并在检测到变化时清空 settings 文件缓存。
733733

734-
当前状态:bootstrap/config/auth/model 基础已完成;settings 已有 merge、managed policysettings file cache/change detector、JSON Schema generation、marketplace source union 基础 validation 和 `strictPluginOnlyCustomization` 基础 enforcement;CLI 已有 `--version`、`--help` 成功退出、`--cwd` working directory override、scaffold settings 校验、基础 `--print` headless 单轮执行路径、基础 `--mcp-config`、基础 input-format text/json/stream-json、`--max-turns` tool loop 限制、基础 JSON result/error 输出、基础 stream-json init/event/error 输出、raw streaming event 透传、headless resume/continue transcript 接线、system prompt flags、dangerously-skip-permissions、常见 camelCase flag aliases、CLI allow/deny tool rules 和 CLI add-dir additional working directory context,但完整参数矩阵、交互 TUI 主循环、resume picker/UI、官方 SDK NDJSON/control protocol、settings live reload/app-state sync 和官方 stdout/stderr/exit-code parity 仍未完整兼容 CC。
734+
当前状态:bootstrap/config/auth/model 基础已完成;settings 已有 merge、managed policy(含本地 file/drop-in、MDM/registry 和可选 remote GET source)、settings file cache/change detector、JSON Schema generation、marketplace source union 基础 validation 和 `strictPluginOnlyCustomization` 基础 enforcement;CLI 已有 `--version`、`--help` 成功退出、`--cwd` working directory override、scaffold settings 校验、基础 `--print` headless 单轮执行路径、基础 `--mcp-config`、基础 input-format text/json/stream-json、`--max-turns` tool loop 限制、基础 JSON result/error 输出、基础 stream-json init/event/error 输出、raw streaming event 透传、headless resume/continue transcript 接线、system prompt flags、dangerously-skip-permissions、常见 camelCase flag aliases、CLI allow/deny tool rules 和 CLI add-dir additional working directory context,但完整参数矩阵、交互 TUI 主循环、resume picker/UI、官方 SDK NDJSON/control protocol、settings live reload/app-state sync、remote managed periodic refresh 和官方 stdout/stderr/exit-code parity 仍未完整兼容 CC。
735735

736736
### M3: API Client And Conversation Loop
737737

docs/claude-code-go-rewrite-plan.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ test/parity/ # golden tests against TS/official behavior
139139
- 本轮补充:新增 no-query `/issue [description]` 本地命令入口,Anthropic client 暴露只读 prompt dump cache 摘要接口;runner 会输出 session/cwd/model、dump path 和最近请求的结构化摘要/hash,不输出 prompt 正文、system 内容或 tool schema 名称,作为后续远端 issue 提交集成的安全上下文基础。
140140
- 本轮补充:`/cost` 本地命令现在会在 runner 带有 `SessionPath` 时从当前 session transcript 回填历史 usage,并按 message UUID/ID 与内存 history 去重,避免 resume 或新进程场景丢失/重复计算历史 cost。
141141
- 本轮补充:Anthropic CLI/env client 初始化现在支持 `ANTHROPIC_CUSTOM_HEADERS``CLAUDE_CODE_CUSTOM_HEADERS`,可用 JSON object 或 `Header: value`/`Header=value` 行格式注入 gateway/proxy 静态请求头;配置错误会在初始化阶段报错,避免静默遗漏代理必需 header。
142-
- 本轮补充:settings loader 现在会按官方优先级读取 managed policy:macOS MDM plist / Windows HKLM 优先,其次平台 managed file `managed-settings.json``managed-settings.d/*.json` drop-ins,最后 Windows HKCU;policy settings 已纳入 runner merged settings、headless model/fastMode 解析、permission engine policy source、MCP policy 和 `/config` 可见文件列表;`allowManagedPermissionRulesOnly` 会剥离非 policy permission rules。
142+
- 本轮补充:settings loader 现在会按官方优先级读取 managed policy:macOS MDM plist / Windows HKLM 优先,其次平台 managed file `managed-settings.json``managed-settings.d/*.json` drop-ins,再读可选 remote managed-settings GET source,最后 Windows HKCU;policy settings 已纳入 runner merged settings、headless model/fastMode 解析、permission engine policy source、MCP policy 和 `/config` 可见文件列表;`allowManagedPermissionRulesOnly` 会剥离非 policy permission rules。
143143
- 本轮补充:`strictPluginOnlyCustomization` 已开始按 policy settings 生效,当前覆盖已实现的 `skills``mcp``hooks` 和 agent-metadata surfaces:锁定后 user/project/local skills 与 legacy commands 不加载,manual MCP server sources 不加载但 plugin/admin policy 仍保留,settings hooks 只保留 policy hooks 且 plugin hooks 继续运行;`agents` 锁定时非 plugin/bundled/admin prompt command 的 `agent``context: fork``effort` frontmatter metadata 会被清除。完整 forked agent runtime/UI edge cases 仍按缺口追踪。
144-
- 本轮补充:settings 文件读取现在有 path-keyed cache,按 size/mode/mtime 指纹复用内容并提供 `ResetSettingsCache`;新增 settings change detector,可对 settings 文件快照区分 created/modified/deleted,并在检测到变化时清空 settings 文件缓存。完整 watcher、remote managed refresh 和 app-state 同步仍按缺口追踪。
144+
- 本轮补充:settings 文件读取现在有 path-keyed cache,按 size/mode/mtime 指纹复用内容并提供 `ResetSettingsCache`;新增 settings change detector,可对 settings 文件快照区分 created/modified/deleted,并在检测到变化时清空 settings 文件缓存。完整 watcher、remote managed periodic refresh 和 app-state 同步仍按缺口追踪。
145145
- 本轮补充:新增 settings JSON Schema generation,`SettingsJSONSchema()` 会从 `contracts.Settings` 反射生成 draft 2020-12 schema,补强 `$schema` const、permission mode enum、`strictPluginOnlyCustomization` union 和 login method enum;`/config show schema` 现在可展示 schema ID、draft、字段数和生成大小,完整 Zod message parity 仍按缺口追踪。
146146
- 本轮补充:settings validation 现在覆盖官方 marketplace source union 的基础语义,适用于 `extraKnownMarketplaces[].source``strictKnownMarketplaces[]``blockedMarketplaces[]`:校验 source discriminator、各 source 类型必填字段、URL source 绝对 URL、headers string record、github/git sparsePaths string array、settings-source plugins array、settings-source name 安全/保留名,并继续覆盖 inline marketplace key/name 一致性。运行时 marketplace source allow/block enforcement 仍按缺口追踪。
147147

docs/first-second-parity-audit.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Anthropic API 和 conversation:
8989
- A basic `Skill` tool wrapper is now registered with the default built-in tool set. It can invoke local project prompt skills through the command registry, returns the official-style `Launching skill: ...` result plus structured command metadata, and passes expanded meta user messages through `ToolResult.NewMessages`; the conversation runner now appends those new messages to transcripts and subsequent model requests.
9090
- Basic slash prompt command invocation is now wired for local project prompt skills: `/skill args` is parsed before the model request, converted into official-shaped command metadata plus expanded meta prompt messages, appended to transcript parent chains, and can override the turn model from skill frontmatter.
9191
- Local prompt-skill slash commands and the `Skill` tool now emit `command_permissions` attachments, parse `allowed-tools` into command-scoped permission rules, and merge those rules into the engine permission decider for the current turn so authorized follow-up tool calls can pass without leaking into later turns.
92-
- Settings schema coverage was expanded for major Claude Code settings keys: auth helpers, model allowlists/overrides, MCP policy, hooks policy, worktree, shell, output style, language, thinking/effort, plugins, remote, spinner, sandbox, and related flags. Settings parsing now also coerces `env` values to strings, filters invalid permission rules into warnings, validates key permission fields, applies WebSearch/WebFetch-specific permission-rule validation, validates marketplace source union basics across `extraKnownMarketplaces`, `strictKnownMarketplaces`, and `blockedMarketplaces` including settings-source map key/source name consistency, loads managed policy from macOS MDM plist / Windows HKLM, platform `managed-settings.json`, sorted `managed-settings.d/*.json` drop-ins, and Windows HKCU fallback, honors `allowManagedPermissionRulesOnly` for permission-rule merging, enforces `strictPluginOnlyCustomization` for the implemented `skills`, `mcp`, and `hooks` surfaces so user/project/local customizations are skipped while plugin/admin sources remain, strips untrusted prompt-command `agent`/`context: fork`/`effort` metadata when the `agents` surface is policy-locked while preserving plugin/bundled/admin sources, includes a path-keyed settings file cache plus a snapshot-based settings change detector that classifies created/modified/deleted settings files and resets cached reads on change, and now generates a JSON Schema from `contracts.Settings` with `/config show schema` summary visibility.
92+
- Settings schema coverage was expanded for major Claude Code settings keys: auth helpers, model allowlists/overrides, MCP policy, hooks policy, worktree, shell, output style, language, thinking/effort, plugins, remote, spinner, sandbox, and related flags. Settings parsing now also coerces `env` values to strings, filters invalid permission rules into warnings, validates key permission fields, applies WebSearch/WebFetch-specific permission-rule validation, validates marketplace source union basics across `extraKnownMarketplaces`, `strictKnownMarketplaces`, and `blockedMarketplaces` including settings-source map key/source name consistency, loads managed policy from macOS MDM plist / Windows HKLM, platform `managed-settings.json`, sorted `managed-settings.d/*.json` drop-ins, optional remote managed-settings GET sources, and Windows HKCU fallback, honors `allowManagedPermissionRulesOnly` for permission-rule merging, enforces `strictPluginOnlyCustomization` for the implemented `skills`, `mcp`, and `hooks` surfaces so user/project/local customizations are skipped while plugin/admin sources remain, strips untrusted prompt-command `agent`/`context: fork`/`effort` metadata when the `agents` surface is policy-locked while preserving plugin/bundled/admin sources, includes a path-keyed settings file cache plus a snapshot-based settings change detector that classifies created/modified/deleted settings files and resets cached reads on change, and now generates a JSON Schema from `contracts.Settings` with `/config show schema` summary visibility.
9393
- Model registry now uses current Claude model IDs and aliases from the source snapshot, including Sonnet 4.6, Opus 4.6, Haiku 4.5, canonical-name rendering, and `[1m]` context variants.
9494
- OAuth support now includes production OAuth config, scope parsing, Claude.ai scope detection, auth URL construction, PKCE verifier/challenge, state generation, and expiry checks.
9595
- Session/history support now includes CC-compatible prompt history references, pasted text/image placeholder parsing, paste-cache hashing and retrieval, `history.jsonl` append/load, current-session-first up-arrow ordering, ctrl+r-style deduped timestamped history, `CLAUDE_CODE_SKIP_PROMPT_HISTORY`, remote session event pagination helpers, lenient transcript loading, legacy progress parent-bridge recovery, compact-boundary pruning, snip removal/relink replay, metadata entry collection, leaf UUID calculation, conversation-chain reconstruction, orphaned parallel tool-result recovery, content-replacement record loading/reconstruction, tombstone metadata delete/relink replay, and tombstone-style transcript message removal with a size guard.
@@ -108,7 +108,7 @@ The following items remain incomplete and must not be treated as done:
108108
- Full tool execution parity gaps that remain: complete hook runtime policy beyond the current settings command hook path, MCP elicitation, complete SDK control event surface beyond current progress NDJSON, mid-call cancellation for concrete tools, background task behavior, telemetry, schema-not-sent hints, and concrete tool-specific semantics.
109109
- Complete Anthropic API parity gaps that remain: dynamic beta-header latching for any remaining provider-specific feature gates beyond prompt-cache/cache-editing/strict-output/1M-context requests, ant-only dump gating and remote `/issue` submission integration beyond the current local context summary, full official cost tracker/session restore lifecycle beyond current transcript usage restore, post-handshake streaming failure semantics, deeper gateway/proxy auth and routing behavior beyond static custom headers, first-party/Bedrock/Vertex/Foundry client setup, deeper OAuth account/profile lifecycle beyond request-time refresh retry, fast-mode retry/cooldown semantics, persistent unattended retry heartbeats, full prompt-cache editing lifecycle, and provider-specific cache behavior.
110110
- Full conversation/query loop: stop hooks, compact/auto-compact, token budget escalation, resume, SDK JSON/NDJSON control events, status updates, rate-limit handling, model switch breadcrumbs, side questions.
111-
- Full settings parity gaps that remain: complete Zod-equivalent validation messages, remote managed-settings loading and refresh, remaining forked agent/frontmatter execution and UI edge cases beyond current policy metadata filtering, runtime marketplace source allow/block enforcement through marketplace install/load flows, and full live reload/app-state sync.
111+
- Full settings parity gaps that remain: complete Zod-equivalent validation messages, remote managed-settings watcher/periodic refresh and app-state propagation beyond the current explicit GET loader, remaining forked agent/frontmatter execution and UI edge cases beyond current policy metadata filtering, runtime marketplace source allow/block enforcement through marketplace install/load flows, and full live reload/app-state sync.
112112
- Full session/history parity gaps that remain: large-file optimized transcript loading, preserved-segment edge cases beyond current relink/prune support, content-replacement feature-flag/runtime override and inherited subagent gap-fill details, complete async prompt-history lifecycle parity beyond current lock/buffer/undo paths, full pasted-image processing/runtime integration beyond current prompt image-cache/image-block/metadata path, remaining remote-history edge cases, sidechain/subagent transcript layout, and all session metadata entry types.
113113

114114
## Current Verification

0 commit comments

Comments
 (0)