(self, config: Config)
| 124 | # Custom MCP-server tools (added via `--mcp-config`) are not auto-approved under |
| 125 | # `acceptEdits`, and `bypassPermissions` may be disabled by an org managed |
| 126 | # policy (see the cwd note below), so caw's `--dangerously-skip-permissions` |
| 127 | # alone is not enough: CodeWiki's own toolkit (str_replace_editor, |
| 128 | # read_code_components, generate_sub_module_documentation) gets denied |
| 129 | # ("you haven't granted it yet"), the agent writes nothing, and the run |
| 130 | # "succeeds" with an empty module tree. Grant the toolkit explicitly with |
| 131 | # `--allowedTools` using the permission rule syntax: |
| 132 | # https://code.claude.com/docs/en/settings#permission-rule-syntax |
| 133 | # `--allowedTools` flag: https://code.claude.com/docs/en/cli-reference |
| 134 | # caw's ClaudeCodeSession only ever emits `--disallowedTools`, so rewrite its |
| 135 | # `claude` command to add `--allowedTools mcp__<server>` for every server in |
| 136 | # the --mcp-config. The patch swaps the `subprocess` module reference INSIDE |
| 137 | # caw.providers.claude_code for a thin proxy — the global subprocess.Popen |
| 138 | # class stays untouched (isinstance / subclass safe) and no other claude |
| 139 | # invocation in this process is affected. Belongs upstream in caw; remove |
| 140 | # once it grows a first-class allowed_tools knob for its toolkit servers. |
| 141 | _CLAUDE_ALLOWED_PATCH_APPLIED = False |
| 142 | |
| 143 | |
| 144 | def _with_allowed_tools(cmd): |
| 145 | """Append ``--allowedTools mcp__<server>,...`` to a ``claude`` command. |
| 146 | |
| 147 | Pure ``list -> list`` transform. Applies only when *cmd* is a claude |
| 148 | invocation carrying ``--mcp-config`` and no explicit allow-list already; |
| 149 | otherwise (or on any error) *cmd* is returned unchanged. |
| 150 | """ |
| 151 | import json |
| 152 |
nothing calls this directly
no test coverage detected