Skip to content

Commit

Permalink
feat: ✨ enforce diff line limits and add system.diff
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Oct 15, 2024
1 parent 18c5fc3 commit 4d79d25
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/src/content/docs/reference/scripts/system.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/genaisrc/system.diff.genai.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/systems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 4d79d25

Please sign in to comment.