feat: improve agent model selection and remote source analysis; bump to 1.2.23
This commit is contained in:
@@ -43,10 +43,14 @@ export async function runAgentFileTool(root: string, request: AgentToolRequest):
|
||||
try {
|
||||
const content = await readText(root, path)
|
||||
const lines = content.split('\n')
|
||||
const partial = args.startLine !== undefined || args.lineCount !== undefined || content.length > 40_000
|
||||
const startLine = args.startLine ?? 1
|
||||
const selected = partial ? lines.slice(startLine - 1, startLine - 1 + (args.lineCount ?? 200)).join('\n').slice(0, 40_000) : content
|
||||
return { data: { path, exists: true, hash: agentFileHash(content), content: selected, complete: !partial, startLine, totalLines: lines.length }, truncated: partial }
|
||||
const ranged = args.startLine !== undefined || args.lineCount !== undefined || content.length > 40_000
|
||||
const selection = ranged ? lines.slice(startLine - 1, startLine - 1 + (args.lineCount ?? 200)).join('\n') : content
|
||||
const selected = selection.slice(0, 40_000)
|
||||
const contentTruncated = selected.length < selection.length
|
||||
const complete = startLine === 1 && selected === content
|
||||
const endLine = Math.min(lines.length, startLine + selected.split('\n').length - 1 - Number(contentTruncated))
|
||||
return { data: { path, exists: true, hash: agentFileHash(content), content: selected, complete, startLine, endLine, contentTruncated, totalLines: lines.length }, truncated: !complete }
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error
|
||||
// A missing leaf in an existing directory is evidence for a new file.
|
||||
|
||||
@@ -116,10 +116,15 @@ else:
|
||||
try:
|
||||
content = read(root, path)
|
||||
lines = content.split('\n')
|
||||
partial = 'startLine' in options or 'lineCount' in options or len(content) > 40000
|
||||
ranged = 'startLine' in options or 'lineCount' in options or len(content) > 40000
|
||||
start = options.get('startLine', 1)
|
||||
selected = '\n'.join(lines[start-1:start-1+options.get('lineCount', 200)])[:40000] if partial else content
|
||||
data = {'path': path, 'exists': True, 'hash': digest(content), 'content': selected, 'complete': not partial, 'startLine': start, 'totalLines': len(lines)}
|
||||
selection = '\n'.join(lines[start-1:start-1+options.get('lineCount', 200)]) if ranged else content
|
||||
selected = selection[:40000]
|
||||
content_truncated = len(selected) < len(selection)
|
||||
complete = start == 1 and selected == content
|
||||
partial = not complete
|
||||
end = min(len(lines), start + len(selected.split('\n')) - 1 - int(content_truncated))
|
||||
data = {'path': path, 'exists': True, 'hash': digest(content), 'content': selected, 'complete': complete, 'startLine': start, 'endLine': end, 'contentTruncated': content_truncated, 'totalLines': len(lines)}
|
||||
except FileNotFoundError:
|
||||
checked(root, path, True)
|
||||
data, partial = {'path': path, 'exists': False, 'hash': None, 'content': '', 'complete': True}, False
|
||||
|
||||
Reference in New Issue
Block a user