Computes diffs between original and modified files, returns minimal representation as diff or full content, and provides regex for modifications tag.
// Source: https://github.com/mperkins0155/bolt.diy_V2.0 | License: MIT | Copyright 2024 StackBlitz, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { createTwoFilesPatch } from 'diff';
import { MODIFICATIONS_TAG_NAME } from './constants';
import type { FileMap } from '~/lib/stores/files';
export const modificationsRegex = new RegExp(
`^<${MODIFICATIONS_TAG_NAME}>[\\s\\S]*?<\\/${MODIFICATIONS_TAG_NAME}>\\s+`,
'g',
);
interface ModifiedFile {
type: 'diff' | 'file';
content: string;
}
type FileModifications = Record<string, ModifiedFile>;
export function computeFileModifications(files: FileMap, modifiedFiles: Map<string, string>) {
const modifications: FileModifications = {};
let hasModifiedFiles = false;
for (const [filePath, originalContent]
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key