MCPcopy Index your code
hub / github.com/callstack/agent-device / readFillTargetFromPositionals

Function readFillTargetFromPositionals

src/core/interaction-positionals.ts:25–52  ·  view source on GitHub ↗
(positionals: string[])

Source from the content-addressed store, hash-verified

23}
24
25export function readFillTargetFromPositionals(positionals: string[]): DecodedFillTarget {
26 const firstPositional = positionals[0];
27 if (firstPositional?.startsWith('@')) {
28 const text =
29 positionals.length >= 3 ? positionals.slice(2).join(' ') : positionals.slice(1).join(' ');
30 return {
31 kind: 'ref',
32 target: {
33 ref: firstPositional,
34 label: positionals.length >= 3 ? optionalTrimmedText(positionals.slice(1, 2)) : undefined,
35 },
36 text,
37 };
38 }
39 const selectorArgs = splitSelectorFromArgs(positionals, { preferTrailingValue: true });
40 if (selectorArgs) {
41 return {
42 kind: 'selector',
43 target: { selector: selectorArgs.selectorExpression },
44 text: selectorArgs.rest.join(' '),
45 };
46 }
47 return {
48 kind: 'point',
49 target: { x: Number(positionals[0]), y: Number(positionals[1]) },
50 text: positionals.slice(2).join(' '),
51 };
52}
53
54function optionalTrimmedText(parts: string[]): string | undefined {
55 const text = parts.join(' ').trim();

Callers 2

interactions.tsFile · 0.90
parseFillTargetFunction · 0.90

Calls 3

splitSelectorFromArgsFunction · 0.90
startsWithMethod · 0.80
optionalTrimmedTextFunction · 0.70

Tested by

no test coverage detected