From 4d79d25779e05075a60003583152f946d828d0b2 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 15 Oct 2024 21:12:41 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20enforce=20diff=20line=20lim?= =?UTF-8?q?its=20and=20add=20system.diff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/src/content/docs/reference/scripts/system.mdx | 2 +- packages/core/src/genaisrc/system.diff.genai.js | 2 +- packages/core/src/systems.ts | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/src/content/docs/reference/scripts/system.mdx b/docs/src/content/docs/reference/scripts/system.mdx index 55ed1ac16f..bf5bfb125d 100644 --- a/docs/src/content/docs/reference/scripts/system.mdx +++ b/docs/src/content/docs/reference/scripts/system.mdx @@ -608,7 +608,7 @@ The DIFF format should be used to generate diff changes on large files with smal - only emit a couple unmodified lines before and after the changes - keep the diffs AS SMALL AS POSSIBLE - when reading files, ask for line numbers -- minimize the number of unmodified lines +- minimize the number of unmodified lines. DO NOT EMIT MORE THEN 2 UNMODIFIED LINES BEFORE AND AFTER THE CHANGES. Otherwise use the FILE file format. - do NOT generate diff for files that have no changes - do NOT emit diff if lines are the same diff --git a/packages/core/src/genaisrc/system.diff.genai.js b/packages/core/src/genaisrc/system.diff.genai.js index eadedb71c0..f8ab46175f 100644 --- a/packages/core/src/genaisrc/system.diff.genai.js +++ b/packages/core/src/genaisrc/system.diff.genai.js @@ -23,7 +23,7 @@ The DIFF format should be used to generate diff changes on large files with smal - only emit a couple unmodified lines before and after the changes - keep the diffs AS SMALL AS POSSIBLE - when reading files, ask for line numbers -- minimize the number of unmodified lines +- minimize the number of unmodified lines. DO NOT EMIT MORE THEN 2 UNMODIFIED LINES BEFORE AND AFTER THE CHANGES. Otherwise use the FILE file format. - do NOT generate diff for files that have no changes - do NOT emit diff if lines are the same diff --git a/packages/core/src/systems.ts b/packages/core/src/systems.ts index adff8ac324..687f1a0fbe 100644 --- a/packages/core/src/systems.ts +++ b/packages/core/src/systems.ts @@ -8,7 +8,7 @@ import { arrayify } from "./util" /** * Function to resolve and return a list of systems based on the provided script and project. * This function analyzes the script options and JavaScript source code to determine applicable systems. - * + * * @param prj - The project object containing templates and other project-related data. * @param script - An object containing options for the prompt system, model options, and optionally JavaScript source code. * @returns An array of unique system IDs that are applicable based on the analysis. @@ -45,6 +45,7 @@ export function resolveSystems( if (/\Wchangelog\W/i.test(jsSource)) systems.push("system.changelog") else if (/\Wfile\W/i.test(jsSource)) { systems.push("system.files") + systems.push("system.diff") // Add file schema system if schema is used if (useSchema) systems.push("system.files_schema") } @@ -82,7 +83,7 @@ export function resolveSystems( /** * Helper function to resolve tools in the project and return their system IDs. * Finds systems in the project associated with a specific tool. - * + * * @param prj - The project object containing templates and other project-related data. * @param tool - The tool ID to resolve systems for. * @returns An array of system IDs associated with the specified tool. @@ -99,7 +100,7 @@ function resolveSystemFromTools(prj: Project, tool: string): string[] { /** * Function to resolve tools in the project based on provided systems and tools. * This function returns a list of tool objects with their IDs and descriptions. - * + * * @param prj - The project object containing templates and other project-related data. * @param systems - An array of system IDs to resolve tools for. * @param tools - An array of tool IDs to resolve tools for.