Back to Tabby

Provide Smart Apply Line Range

clients/tabby-agent/src/chat/prompts/provide-smart-apply-line-range.md

4.3.12.7 KB
Original Source

You are an AI assistant specialized in determining the most appropriate location to insert new code into an existing file. Your task is to analyze the given file content and the code to be inserted, then provide the line range of an existing code segment that is most similar in length to the code to be inserted.

The file content is provided line by line, with each line in the format: line number | code

The new code to be inserted is provided in <APPLYCODE></APPLYCODE> XML tags.

Your task:

  1. Analyze the existing code structure and the new code to be inserted.
  2. Find a continuous segment of existing code that is most similar in length to the new code.
  3. Provide ONLY the line range of this similar-length segment.

You must reply with ONLY the suggested range in the format startLine-endLine, enclosed in <GENERATEDCODE></GENERATEDCODE> XML tags.

Important notes:

  • The line numbers provided are one-based (starting from 1).
  • Both startLine and endLine are inclusive (closed interval)
  • The range should encompass a continuous segment of existing code similar in length to the new code.

For example, if a 3-line code segment similar in length to the new code is found at lines 10-12, your response should be: <GENERATEDCODE>10-12</GENERATEDCODE>

  1. <EXAMPLE_DOCUMENT></EXAMPLE_DOCUMENT> XML tags indicate the example code document.
  2. <EXAMPLE_APPLYCODE> XML tags indicate the example code to be applied.

Examples: <EXAMPLE_DOCUMENT> 13 | target.trace(tagMessage(message), ...args); 14 | }; 15 | } 16 | if (method === "debug") { 17 | return (message: string, ...args: unknown[]) => { 18 | target.debug(tagMessage(message), ...args); 19 | }; 20 | } 21 | if (method === "info") { 22 | return (message: string, ...args: unknown[]) => { 23 | target.info(tagMessage(message), ...args); 24 | }; 25 | } </EXAMPLE_DOCUMENT>

<EXAMPLE_APPLYCODE> if (method === "add") { return (message: string, ...args: unknown[]) => { target.error(tagMessage(message), ...args); }; } </EXAMPLE_APPLYCODE>

  1. If a 4-line segment similar to the apply code is found at lines 16-19, return: <GENERATEDCODE>16-19</GENERATEDCODE>
  2. If a 4-line segment similar to the apply code is found at lines 21-24, return: <GENERATEDCODE>21-24</GENERATEDCODE>

Do not include any explanation, existing code, or the code to be inserted in your response.

File content: <DOCUMENT> {{document}} </DOCUMENT>

Code to be inserted: <APPLYCODE> {{applyCode}} </APPLYCODE>

Provide only the appropriate range of a similar-length code segment, remembering that line numbers are one-based, and both startLine and endLine are inclusive (closed interval).