MCPcopy Index your code
hub / github.com/anomalyco/opencode / StrictNearestRoot

Function StrictNearestRoot

packages/opencode/src/lsp/server.ts:56–78  ·  view source on GitHub ↗
(includePatterns: string[], excludePatterns?: string[])

Source from the content-addressed store, hash-verified

54}
55
56const StrictNearestRoot = (includePatterns: string[], excludePatterns?: string[]): RootFunction => {
57 return async (file, ctx) => {
58 if (excludePatterns) {
59 const excludedFiles = Filesystem.up({
60 targets: excludePatterns,
61 start: path.dirname(file),
62 stop: ctx.directory,
63 })
64 const excluded = await excludedFiles.next()
65 await excludedFiles.return()
66 if (excluded.value) return undefined
67 }
68 const files = Filesystem.up({
69 targets: includePatterns,
70 start: path.dirname(file),
71 stop: ctx.directory,
72 })
73 const first = await files.next()
74 await files.return()
75 if (!first.value) return undefined
76 return path.dirname(first.value)
77 }
78}
79
80export interface Info {
81 id: string

Callers 1

server.tsFile · 0.85

Calls 1

nextMethod · 0.45

Tested by

no test coverage detected