MCPcopy Create free account
hub / github.com/Noumena-Network/code / relativeSafe

Function relativeSafe

src/utils/agentsmd.ts:108–122  ·  view source on GitHub ↗
(from: string, to: string)

Source from the content-addressed store, hash-verified

106}
107
108function relativeSafe(from: string, to: string): string {
109 const fromParts = from.split(/[/\\]+/).filter(Boolean)
110 const toParts = to.split(/[/\\]+/).filter(Boolean)
111 let common = 0
112 while (
113 common < fromParts.length &&
114 common < toParts.length &&
115 fromParts[common] === toParts[common]
116 ) {
117 common += 1
118 }
119 const up = fromParts.length - common
120 const down = toParts.slice(common)
121 return [...Array(up).fill('..'), ...down].join('/')
122}
123
124/**
125 * Collects AGENTS.md / .agents/ memory files for the current project and user.

Callers 1

pathInWorkingPathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected