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

Function toolPath

packages/opencode/src/cli/cmd/run/tool.ts:250–273  ·  view source on GitHub ↗
(input?: string, opts: { home?: boolean } = {})

Source from the content-addressed store, hash-verified

248}
249
250export function toolPath(input?: string, opts: { home?: boolean } = {}): string {
251 if (!input) {
252 return ""
253 }
254
255 const cwd = process.cwd()
256 const home = os.homedir()
257 const abs = path.isAbsolute(input) ? input : path.resolve(cwd, input)
258 const rel = path.relative(cwd, abs)
259
260 if (!rel) {
261 return "."
262 }
263
264 if (!rel.startsWith("..")) {
265 return rel.replaceAll("\\", "/")
266 }
267
268 if (opts.home && home && (abs === home || abs.startsWith(home + path.sep))) {
269 return abs.replace(home, "~").replaceAll("\\", "/")
270 }
271
272 return abs.replaceAll("\\", "/")
273}
274
275function fallbackInline(ctx: ToolFrame): ToolInline {
276 const title = text(ctx.state.title) || (Object.keys(ctx.input).length > 0 ? JSON.stringify(ctx.input) : "Unknown")

Callers 15

permissionInfoFunction · 0.90
runGlobFunction · 0.85
runGrepFunction · 0.85
runListFunction · 0.85
runReadFunction · 0.85
runWriteFunction · 0.85
runEditFunction · 0.85
lspTitleFunction · 0.85
patchTitleFunction · 0.85
snapWriteFunction · 0.85
snapEditFunction · 0.85
scrollBashStartFunction · 0.85

Calls 1

cwdMethod · 0.65

Tested by

no test coverage detected