Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
21 changes: 21 additions & 0 deletions src/negative_test/claude-code-settings/invalid-enum-coverage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"defaultShell": "zsh",
"defaultView": "list",
"disableAutoMode": "enable",
"hooks": {
"PreToolUse": [
{
"hooks": [
{
"command": "echo 'hook'",
"shell": "zsh",
"type": "command"
}
]
}
]
},
"permissions": {
"disableAutoMode": "enable"
}
}
Loading
Loading