MCPcopy Index your code
hub / github.com/continuedev/continue / rifWithContentsToContextItem

Function rifWithContentsToContextItem

core/commands/util.ts:6–29  ·  view source on GitHub ↗
(
  rif: RangeInFileWithContents,
)

Source from the content-addressed store, hash-verified

4import { findUriInDirs, getUriPathBasename } from "../util/uri";
5
6export function rifWithContentsToContextItem(
7 rif: RangeInFileWithContents,
8): ContextItemWithId {
9 const basename = getUriPathBasename(rif.filepath);
10 const { relativePathOrBasename, foundInDir, uri } = findUriInDirs(
11 rif.filepath,
12 window.workspacePaths ?? [],
13 );
14 const rangeStr = `(${rif.range.start.line + 1}-${rif.range.end.line + 1})`;
15
16 return {
17 content: rif.contents,
18 name: `${basename} ${rangeStr}`,
19 description: `${relativePathOrBasename} ${rangeStr}`,
20 id: {
21 providerTitle: "code",
22 itemId: uuidv4(),
23 },
24 uri: {
25 type: "file",
26 value: rif.filepath,
27 },
28 };
29}
30
31export function ctxItemToRifWithContents(
32 item: ContextItemWithId,

Callers 1

Calls 2

getUriPathBasenameFunction · 0.90
findUriInDirsFunction · 0.90

Tested by

no test coverage detected