• Will Chen's avatar
    Use Claude Sonnet to decide permission requests (#2319) · 68f4de78
    Will Chen 提交于
    ## Summary
    - Fix PermissionRequest hook to use correct hookSpecificOutput JSON
    wrapper format
    - Previously the hook output {behavior: allow} but Claude Code expects
    {hookSpecificOutput: {hookEventName: PermissionRequest, decision:
    {behavior: allow}}}
    - Clean up code: remove debug logging, organize imports
    
    ## Test plan
    - Run a command that triggers permission request (e.g., rm -rf somedir)
    - Verify the hook auto-approves GREEN operations without showing the
    permission dialog
    - Test with DEBUG_PERMISSION_HOOK=1 to see hook execution logs
    
    Generated with Claude Code
    
    
    <!-- This is an auto-generated description by cubic. -->
    ---
    ## Summary by cubic
    Uses Claude Sonnet to analyze permission requests and fixes the
    PermissionRequest hook output format so decisions are applied correctly.
    GREEN auto-approves, YELLOW passes through, RED auto-denies without
    showing the dialog.
    
    - **Bug Fixes**
    - Use the correct wrapper: {hookSpecificOutput: {hookEventName:
    "PermissionRequest", decision: {behavior: "allow"|"deny"}}}.
      - Improve JSON extraction; remove debug logs and tidy imports.
    
    - **New Features**
    - Add permission-request-hook.py to analyze requests with Claude CLI
    (sonnet) and auto-approve/deny using permission-policy.md.
      - Add tests for hook behavior, response schema, and policy coverage.
      - Enable the hook in .claude/settings.json for all tools.
    
    <sup>Written for commit bcdcd4eeda5e28d4cde37247fae8c150c1e9ba1b.
    Summary will update on new commits.</sup>
    
    <!-- End of auto-generated description by cubic. -->
    
    
    
    
    <!-- CURSOR_SUMMARY -->
    ---
    
    > [!NOTE]
    > Introduces an AI-driven PermissionRequest hook that evaluates tool
    actions against a new security policy and auto-approves/denies
    accordingly, plus tests and settings wiring.
    > 
    > - **Add** `permission-request-hook.py` to call Claude (model `sonnet`)
    with `permission-policy.md`, parse JSON robustly, and emit
    `hookSpecificOutput` for `allow`/`deny` (GREEN auto-approve, RED
    auto-deny, YELLOW passthrough)
    > - **Add** comprehensive `permission-policy.md` covering Bash, GitHub,
    and file operations with GREEN/YELLOW/RED criteria
    > - **Add** tests in `tests/test_permission_request_hook.py` for hook
    passthrough behavior, response format, CLI absence, and policy coverage
    > - **Configure** `.claude/settings.json` to register the new
    PermissionRequest hook for all tools with a 30s timeout
    > 
    > <sup>Written by [Cursor
    Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
    bcdcd4eeda5e28d4cde37247fae8c150c1e9ba1b. This will update automatically
    on new commits. Configure
    [here](https://cursor.com/dashboard?tab=bugbot).</sup>
    <!-- /CURSOR_SUMMARY -->
    
    ---------
    Co-authored-by: 's avatarClaude Opus 4.5 <noreply@anthropic.com>
    68f4de78
名称
最后提交
最后更新
.claude 正在载入提交数据...
.cursor/rules 正在载入提交数据...
.devcontainer 正在载入提交数据...
.github 正在载入提交数据...
.husky 正在载入提交数据...
assets 正在载入提交数据...
docs 正在载入提交数据...
drizzle 正在载入提交数据...
e2e-tests 正在载入提交数据...
makers 正在载入提交数据...
packages/@dyad-sh 正在载入提交数据...
scaffold 正在载入提交数据...
scripts 正在载入提交数据...
shared 正在载入提交数据...
src 正在载入提交数据...
testing 正在载入提交数据...
tools 正在载入提交数据...
worker 正在载入提交数据...
workers/tsc 正在载入提交数据...
.cursorignore 正在载入提交数据...
.env.example 正在载入提交数据...
.eslintrc.json 正在载入提交数据...
.gitattributes 正在载入提交数据...
.gitignore 正在载入提交数据...
.oxfmtrc.json 正在载入提交数据...
.oxlintrc.json 正在载入提交数据...
.prettierignore 正在载入提交数据...
.prettierrc 正在载入提交数据...
AGENTS.md 正在载入提交数据...
CLA.md 正在载入提交数据...
CLAUDE.md 正在载入提交数据...
CONTRIBUTING.md 正在载入提交数据...
LICENSE 正在载入提交数据...
README.md 正在载入提交数据...
SECURITY.md 正在载入提交数据...
biome.json 正在载入提交数据...
components.json 正在载入提交数据...
drizzle.config.ts 正在载入提交数据...
forge.config.ts 正在载入提交数据...
forge.env.d.ts 正在载入提交数据...
index.html 正在载入提交数据...
lint-staged.config.js 正在载入提交数据...
merge.config.ts 正在载入提交数据...
package-lock.json 正在载入提交数据...
package.json 正在载入提交数据...
playwright.config.ts 正在载入提交数据...
tsconfig.app.json 正在载入提交数据...
tsconfig.json 正在载入提交数据...
tsconfig.node.json 正在载入提交数据...
vite.main.config.mts 正在载入提交数据...
vite.preload.config.mts 正在载入提交数据...
vite.renderer.config.mts 正在载入提交数据...
vite.worker.config.mts 正在载入提交数据...
vitest.config.ts 正在载入提交数据...