MCPcopy Index your code
hub / github.com/deepnote/deepnote / suggestSimilarFiles

Function suggestSimilarFiles

packages/cli/src/utils/file-resolver.ts:165–197  ·  view source on GitHub ↗

* Suggest similar files if the specified file doesn't exist.

(path: string)

Source from the content-addressed store, hash-verified

163 * Suggest similar files if the specified file doesn't exist.
164 */
165async function suggestSimilarFiles(path: string): Promise<string> {
166 try {
167 const dir = dirname(path) || '.'
168 const filename = basename(path)
169 const resolvedDir = resolve(process.cwd(), dir)
170
171 const files = await readdir(resolvedDir)
172 const deepnoteFiles = files.filter(f => f.toLowerCase().endsWith('.deepnote'))
173
174 if (deepnoteFiles.length === 0) {
175 return '\n\nNo .deepnote files found in this directory.'
176 }
177
178 // Find similar filenames
179 const similar = deepnoteFiles
180 .filter(f => {
181 const baseName = basename(filename, extname(filename))
182 return f.toLowerCase().includes(baseName.toLowerCase())
183 })
184 .slice(0, 3)
185
186 if (similar.length > 0) {
187 return `\n\nDid you mean?\n${similar.map(f => ` - ${f}`).join('\n')}`
188 }
189
190 // Show available files
191 const available = deepnoteFiles.slice(0, 5)
192 const more = deepnoteFiles.length > 5 ? `\n ... and ${deepnoteFiles.length - 5} more` : ''
193 return `\n\nAvailable .deepnote files:\n${available.map(f => ` - ${f}`).join('\n')}${more}`
194 } catch {
195 return ''
196 }
197}
198
199/**
200 * Get a helpful hint based on the file extension.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected