|
| 1 | +import assert from 'node:assert/strict'; |
| 2 | +import { test } from 'vitest'; |
| 3 | +import { listCommandTools } from '../command-tools.ts'; |
| 4 | + |
| 5 | +// Guidance no longer restates input fields in prose, so a tool's inputSchema is the only |
| 6 | +// place its inputs are documented — for the model, for `--help`, and for the docs site. An |
| 7 | +// undescribed property is therefore a silent gap rather than a cosmetic one. |
| 8 | +// |
| 9 | +// The baseline pins exact `tool.property` identities, not bare property names plus a total: |
| 10 | +// a name-and-count baseline stays green when a gap migrates (describe `foo.text`, add an |
| 11 | +// undescribed `bar.text`, and both the allowed-name set and the total are unchanged), and |
| 12 | +// stale names keep authorizing gaps that appear later. Exact identities make every new or |
| 13 | +// moved gap fail, and require deleting an entry to record a fix. |
| 14 | +const UNDESCRIBED_TOOL_INPUTS = new Set([ |
| 15 | + 'alert.action', |
| 16 | + 'alert.timeoutMs', |
| 17 | + 'audio.action', |
| 18 | + 'audio.probeAction', |
| 19 | + 'back.mode', |
| 20 | + 'clipboard.action', |
| 21 | + 'clipboard.text', |
| 22 | + 'close.saveScript', |
| 23 | + 'debug.action', |
| 24 | + 'diff.depth', |
| 25 | + 'diff.interactiveOnly', |
| 26 | + 'diff.kind', |
| 27 | + 'diff.out', |
| 28 | + 'diff.raw', |
| 29 | + 'diff.scope', |
| 30 | + 'events.cursor', |
| 31 | + 'events.limit', |
| 32 | + 'find.action', |
| 33 | + 'find.depth', |
| 34 | + 'find.first', |
| 35 | + 'find.last', |
| 36 | + 'find.locator', |
| 37 | + 'find.query', |
| 38 | + 'find.raw', |
| 39 | + 'find.timeoutMs', |
| 40 | + 'find.value', |
| 41 | + 'get.format', |
| 42 | + 'install-from-source.retainPaths', |
| 43 | + 'install-from-source.retentionMs', |
| 44 | + 'is.predicate', |
| 45 | + 'is.selector', |
| 46 | + 'is.value', |
| 47 | + 'keyboard.action', |
| 48 | + 'logs.action', |
| 49 | + 'logs.message', |
| 50 | + 'logs.restart', |
| 51 | + 'metro.action', |
| 52 | + 'metro.bridgeScope', |
| 53 | + 'metro.bundleUrl', |
| 54 | + 'metro.installDependenciesIfNeeded', |
| 55 | + 'metro.kind', |
| 56 | + 'metro.launchUrl', |
| 57 | + 'metro.listenHost', |
| 58 | + 'metro.logPath', |
| 59 | + 'metro.metroHost', |
| 60 | + 'metro.metroPort', |
| 61 | + 'metro.port', |
| 62 | + 'metro.probeTimeoutMs', |
| 63 | + 'metro.projectRoot', |
| 64 | + 'metro.publicBaseUrl', |
| 65 | + 'metro.reuseExisting', |
| 66 | + 'metro.runtimeFilePath', |
| 67 | + 'metro.startupTimeoutMs', |
| 68 | + 'metro.statusHost', |
| 69 | + 'metro.timeoutMs', |
| 70 | + 'network.action', |
| 71 | + 'network.include', |
| 72 | + 'network.limit', |
| 73 | + 'open.saveScript', |
| 74 | + 'orientation.orientation', |
| 75 | + 'perf.action', |
| 76 | + 'perf.area', |
| 77 | + 'perf.kind', |
| 78 | + 'perf.subject', |
| 79 | + 'push.app', |
| 80 | + 'push.payload', |
| 81 | + 'react-native.action', |
| 82 | + 'record.action', |
| 83 | + 'record.fps', |
| 84 | + 'record.hideTouches', |
| 85 | + 'record.path', |
| 86 | + 'record.quality', |
| 87 | + 'record.recordingScope', |
| 88 | + 'reinstall.app', |
| 89 | + 'replay.backend', |
| 90 | + 'replay.env', |
| 91 | + 'replay.force', |
| 92 | + 'replay.maestro', |
| 93 | + 'replay.path', |
| 94 | + 'replay.resumeFrom', |
| 95 | + 'replay.resumePlanDigest', |
| 96 | + 'replay.saveScript', |
| 97 | + 'replay.update', |
| 98 | + 'screenshot.fullscreen', |
| 99 | + 'screenshot.normalizeStatusBar', |
| 100 | + 'screenshot.overlayRefs', |
| 101 | + 'screenshot.stabilize', |
| 102 | + 'screenshot.surface', |
| 103 | + 'scroll.direction', |
| 104 | + 'settings.app', |
| 105 | + 'settings.latitude', |
| 106 | + 'settings.longitude', |
| 107 | + 'settings.mode', |
| 108 | + 'settings.permission', |
| 109 | + 'settings.setting', |
| 110 | + 'settings.state', |
| 111 | + 'snapshot.depth', |
| 112 | + 'snapshot.forceFull', |
| 113 | + 'snapshot.interactiveOnly', |
| 114 | + 'snapshot.raw', |
| 115 | + 'snapshot.scope', |
| 116 | + 'swipe.pattern', |
| 117 | + 'test.artifactsDir', |
| 118 | + 'test.backend', |
| 119 | + 'test.env', |
| 120 | + 'test.failFast', |
| 121 | + 'test.maestro', |
| 122 | + 'test.paths', |
| 123 | + 'test.recordVideo', |
| 124 | + 'test.retries', |
| 125 | + 'test.shardAll', |
| 126 | + 'test.shardSplit', |
| 127 | + 'test.timeoutMs', |
| 128 | + 'test.update', |
| 129 | + 'trace.action', |
| 130 | + 'trace.path', |
| 131 | + 'tv-remote.button', |
| 132 | + 'wait.depth', |
| 133 | + 'wait.durationMs', |
| 134 | + 'wait.absent', |
| 135 | + 'wait.kind', |
| 136 | + 'wait.quietMs', |
| 137 | + 'wait.raw', |
| 138 | + 'wait.ref', |
| 139 | + 'wait.scope', |
| 140 | + 'wait.selector', |
| 141 | + 'wait.stable', |
| 142 | + 'wait.text', |
| 143 | + 'wait.timeoutMs', |
| 144 | +]); |
| 145 | + |
| 146 | +test('MCP tool inputs do not add undocumented properties', () => { |
| 147 | + const undescribed: string[] = []; |
| 148 | + for (const tool of listCommandTools()) { |
| 149 | + for (const [key, schema] of Object.entries(tool.inputSchema.properties ?? {})) { |
| 150 | + if (!schema.description) undescribed.push(`${tool.name}.${key}`); |
| 151 | + } |
| 152 | + } |
| 153 | + |
| 154 | + const added = undescribed.filter((entry) => !UNDESCRIBED_TOOL_INPUTS.has(entry)).sort(); |
| 155 | + assert.deepEqual( |
| 156 | + added, |
| 157 | + [], |
| 158 | + `These MCP tool inputs need a schema description: ${added.join(', ')}`, |
| 159 | + ); |
| 160 | + |
| 161 | + const fixed = [...UNDESCRIBED_TOOL_INPUTS].filter((entry) => !undescribed.includes(entry)).sort(); |
| 162 | + assert.deepEqual( |
| 163 | + fixed, |
| 164 | + [], |
| 165 | + `These MCP tool inputs are documented now — remove them from UNDESCRIBED_TOOL_INPUTS: ${fixed.join(', ')}`, |
| 166 | + ); |
| 167 | +}); |
0 commit comments