Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/helpers/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,33 @@ function collectPropertyValues(data, propName) {
// matching is deferred to v2.
function collectValuesByPath(data, path) {
const values = []

// For $defs paths (e.g. "#$defs/hookCommand.shell"), path-based traversal
// cannot work because the path references the schema definition, not the
// test data structure. Fall back to a deep name-based search for the
// terminal property name so that test files exercising the property via
// $ref usage are still matched.
if (path.startsWith('#')) {
const propName = path.split('.').pop()
function deepCollect(current) {
if (!current || typeof current !== 'object') return
if (Array.isArray(current)) {
for (const item of current) deepCollect(item)
return
}
for (const [key, val] of Object.entries(current)) {
if (key === propName && val !== undefined && val !== null) {
values.push(val)
}
if (typeof val === 'object' && val !== null) {
deepCollect(val)
}
}
}
deepCollect(data)
return values
}

const segments = path.split('.')

function traverse(current, remaining) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"autoUpdatesChannel": "beta",
"defaultShell": "zsh",
"disableDeepLinkRegistration": "enabled",
"effortLevel": "extreme",
"forceLoginMethod": "github",
"permissions": {
"defaultMode": "invalid-mode",
"disableAutoMode": "enabled",
"disableBypassPermissionsMode": "enabled"
},
"spinnerVerbs": {
"mode": "merge",
"verbs": ["Analyzing"]
},
"teammateMode": "split"
"teammateMode": "split",
"tui": "mini",
"viewMode": "list"
}
16 changes: 16 additions & 0 deletions src/negative_test/claude-code-settings/invalid-hook-shell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"hooks": {
"PreToolUse": [
{
"hooks": [
{
"command": "echo test",
"shell": "fish",
"type": "command"
}
],
"matcher": "Bash"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"hooks": [
{
"type": "command"
},
{
"tool": "lint_file",
"type": "mcp_tool"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"sandbox": {
"network": {
"allowAllUnixSockets": "yes",
"allowedDomains": "api.anthropic.com"
"allowedDomains": "api.anthropic.com",
"deniedDomains": "should-be-array"
}
},
"strictKnownMarketplaces": [
Expand Down
281 changes: 270 additions & 11 deletions src/schemas/json/claude-code-settings.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/test/claude-code-settings/complete-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"apiKeyHelper": "/usr/local/bin/claude-auth",
"cleanupPeriodDays": 30,
"effortLevel": "medium",
"env": {
"DEBUG_MODE": "true",
"EDITOR": "vim"
Expand All @@ -22,5 +23,6 @@
"Bash(wget:*)",
"WebFetch(domain:bad.actor.com)"
]
}
},
"viewMode": "default"
}
2 changes: 1 addition & 1 deletion src/test/claude-code-settings/edge-cases.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"autoUpdatesChannel": "stable",
"cleanupPeriodDays": 0,
"cleanupPeriodDays": 1,
"effortLevel": "low",
"env": {},
"fastMode": false,
Expand Down
28 changes: 28 additions & 0 deletions src/test/claude-code-settings/enum-coverage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"channelsEnabled": false,
"defaultShell": "bash",
"effortLevel": "xhigh",
"hooks": {
"PreToolUse": [
{
"hooks": [
{
"command": "echo bash",
"shell": "bash",
"type": "command"
},
{
"command": "Get-Content",
"shell": "powershell",
"type": "command"
}
],
"matcher": "Bash"
}
]
},
"terminalTitleFromRename": true,
"tui": "fullscreen",
"viewMode": "verbose"
}
10 changes: 10 additions & 0 deletions src/test/claude-code-settings/hooks-complete.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@
"command": "git diff",
"statusMessage": "Reviewing changes",
"type": "command"
},
{
"input": {
"file": "${tool_input.file_path}"
},
"server": "linter",
"statusMessage": "Linting edited file",
"timeout": 30,
"tool": "lint_file",
"type": "mcp_tool"
}
],
"matcher": "Edit"
Expand Down
6 changes: 4 additions & 2 deletions src/test/claude-code-settings/managed-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"enabled": true,
"network": {
"allowManagedDomainsOnly": true,
"allowedDomains": ["*.company.com", "registry.npmjs.org"]
"allowedDomains": ["*.company.com", "registry.npmjs.org"],
"deniedDomains": ["blocked.example.com"]
}
}
},
"wslInheritsWindowsSettings": true
}
65 changes: 62 additions & 3 deletions src/test/claude-code-settings/modern-complete-config.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"agent": "code-reviewer",
"allowManagedHooksOnly": false,
"allowManagedPermissionRulesOnly": false,
"allowedChannelPlugins": ["internal-notifier@corp"],
"allowedHttpHookUrls": ["https://hooks.example.com/*", "http://localhost:*"],
"alwaysThinkingEnabled": false,
"apiKeyHelper": "/usr/local/bin/claude-auth-helper",
"attribution": {
"commit": "Generated with AI\n\nCo-Authored-By: AI <ai@example.com>",
"pr": ""
},
"autoMemoryDirectory": "~/.claude/custom-memory",
"autoMemoryEnabled": false,
"autoMode": {
"allow": ["$defaults", "All read-only operations"],
"environment": ["$defaults", "WSL2 on Windows"],
"soft_deny": ["$defaults", "Deleting files"]
},
"autoUpdatesChannel": "latest",
"availableModels": ["sonnet", "haiku"],
"awsAuthRefresh": "aws sso login --profile myprofile",
Expand All @@ -20,15 +28,19 @@
"source": "pathPattern"
}
],
"channelsEnabled": true,
"claudeMdExcludes": [
"**/other-team/CLAUDE.md",
"/home/user/monorepo/.claude/rules/**"
],
"cleanupPeriodDays": 60,
"companyAnnouncements": ["Welcome to the team!"],
"defaultShell": "powershell",
"disableAllHooks": false,
"disableDeepLinkRegistration": "disable",
"disableSkillShellExecution": false,
"disabledMcpjsonServers": ["untrusted-server"],
"effortLevel": "medium",
"effortLevel": "max",
"enableAllProjectMcpServers": true,
"enabledPlugins": {
"formatter@anthropic-tools": true
Expand Down Expand Up @@ -56,6 +68,7 @@
},
"forceLoginMethod": "console",
"forceLoginOrgUUID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"forceRemoteSettingsRefresh": false,
"hooks": {
"ConfigChange": [
{
Expand Down Expand Up @@ -103,8 +116,19 @@
{
"hooks": [
{
"asyncRewake": true,
"command": "echo 'File write detected' >> ~/.claude-code/activity.log",
"if": "Write(**/*.py)",
"shell": "bash",
"type": "command"
},
{
"input": {
"file": "${tool_input.file_path}"
},
"server": "linter",
"tool": "lint_file",
"type": "mcp_tool"
}
],
"matcher": "Write"
Expand All @@ -131,6 +155,16 @@
]
}
],
"StopFailure": [
{
"hooks": [
{
"command": "echo 'Stop failed' >> ~/.claude-code/errors.log",
"type": "command"
}
]
}
],
"WorktreeCreate": [
{
"hooks": [
Expand All @@ -156,6 +190,7 @@
"includeCoAuthoredBy": true,
"includeGitInstructions": false,
"language": "english",
"minimumVersion": "2.1.0",
"model": "opus",
"modelOverrides": {
"claude-opus-4-6": "arn:aws:bedrock:us-east-2:123456789012:application-inference-profile/opus-prod"
Expand Down Expand Up @@ -186,7 +221,8 @@
"Bash(rm -rf:*)",
"Write(/etc/**)",
"Write(/System/**)"
]
],
"disableAutoMode": "disable"
},
"plansDirectory": "./plans",
"pluginConfigs": {
Expand All @@ -195,10 +231,15 @@
"formatter": {
"autoFormat": "true"
}
},
"options": {
"lineWidth": 80,
"useTabs": false
}
}
},
"pluginTrustMessage": "All plugins from our internal marketplace are pre-approved by the security team.",
"prUrlTemplate": "https://reviews.example.com/{owner}/{repo}/pull/{number}",
"prefersReducedMotion": true,
"respectGitignore": false,
"sandbox": {
Expand All @@ -209,21 +250,32 @@
"enabled": true,
"excludedCommands": ["docker", "git"],
"filesystem": {
"allowManagedReadPathsOnly": false,
"allowRead": ["~/.ssh/known_hosts"],
"allowWrite": ["~/.kube", "//tmp/build"],
"denyRead": ["~/.ssh/id_rsa"],
"denyWrite": ["//etc", "//usr"]
},
"network": {
"allowAllUnixSockets": false,
"allowLocalBinding": true,
"allowMachLookup": ["com.apple.coresimulator.*"],
"allowManagedDomainsOnly": true,
"allowUnixSockets": ["/var/run/docker.sock"],
"allowedDomains": ["github.com", "*.npmjs.org", "registry.yarnpkg.com"],
"deniedDomains": ["ads.example.com", "*.tracker.com"],
"httpProxyPort": 8080,
"socksProxyPort": 8081
},
"ripgrep": {
"args": ["--hidden"],
"command": "/usr/bin/rg"
}
},
"showClearContextOnPlanAccept": true,
"showThinkingSummaries": true,
"showTurnDuration": false,
"skipDangerousModePermissionPrompt": true,
"skipWebFetchPreflight": false,
"skippedMarketplaces": ["untrusted-marketplace"],
"skippedPlugins": ["risky-plugin@unknown-marketplace"],
Expand All @@ -239,11 +291,18 @@
"statusLine": {
"command": "~/.claude/statusline.sh",
"padding": 1,
"refreshInterval": 5,
"type": "command"
},
"strictPluginOnlyCustomization": ["skills", "hooks"],
"teammateMode": "tmux",
"terminalProgressBarEnabled": false,
"tui": "default",
"useAutoModeDuringPlan": true,
"viewMode": "focus",
"voiceEnabled": true,
"worktree": {
"sparsePaths": ["packages/my-app", "shared/utils"]
}
},
"wslInheritsWindowsSettings": false
}