editcodewithai 0.1.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -30
- package/dist/fileUtils.d.ts +3 -9
- package/dist/fileUtils.js +15 -11
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/types.d.ts +8 -7
- package/package.json +19 -9
- package/dist/benchmark.d.ts +0 -37
- package/dist/benchmark.js +0 -123
- package/dist/benchmarks/benchmarkRunner.d.ts +0 -5
- package/dist/benchmarks/benchmarkRunner.js +0 -85
- package/dist/benchmarks/challenges.d.ts +0 -2
- package/dist/benchmarks/challenges.js +0 -158
- package/dist/benchmarks/fileUtils.d.ts +0 -15
- package/dist/benchmarks/fileUtils.js +0 -55
- package/dist/benchmarks/index.d.ts +0 -5
- package/dist/benchmarks/index.js +0 -44
- package/dist/benchmarks/llm.d.ts +0 -10
- package/dist/benchmarks/llm.js +0 -29
- package/dist/benchmarks/models.d.ts +0 -1
- package/dist/benchmarks/models.js +0 -21
- package/dist/benchmarks/runner.d.ts +0 -4
- package/dist/benchmarks/runner.js +0 -35
- package/dist/benchmarks/types.d.ts +0 -16
- package/dist/benchmarks/types.js +0 -2
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -157
- package/dist/computeInitialDocument.d.ts +0 -13
- package/dist/computeInitialDocument.js +0 -135
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.computeInitialDocument = exports.isDirectory = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const ignore_1 = __importDefault(require("ignore"));
|
|
10
|
-
// Configuration constants
|
|
11
|
-
const ignoreFilePattern = '**/{.ignore,.gitignore}';
|
|
12
|
-
const baseIgnore = [
|
|
13
|
-
'.git',
|
|
14
|
-
'node_modules',
|
|
15
|
-
'dist',
|
|
16
|
-
'*.log',
|
|
17
|
-
'.DS_Store',
|
|
18
|
-
'coverage',
|
|
19
|
-
'.env',
|
|
20
|
-
'.env.*',
|
|
21
|
-
];
|
|
22
|
-
const debugIgnore = false;
|
|
23
|
-
const debugDirectories = false;
|
|
24
|
-
const enableDirectories = true;
|
|
25
|
-
/**
|
|
26
|
-
* @param {string} fullPath - absolute path of the workspace root
|
|
27
|
-
* @param {string} currentDirectoryPath - path where the ignore file is found, relative to fullPath
|
|
28
|
-
* @param {string} fileName - name of the ignore file
|
|
29
|
-
* @returns {string[]} parsed lines
|
|
30
|
-
*/
|
|
31
|
-
const parseIgnoreFile = (fullPath, currentDirectory, fileName) => {
|
|
32
|
-
const filePath = path_1.default.join(fullPath, currentDirectory, fileName);
|
|
33
|
-
const content = fs_1.default.readFileSync(filePath, 'utf8');
|
|
34
|
-
const globs = content
|
|
35
|
-
.split(/[\n\r]+/)
|
|
36
|
-
.filter(
|
|
37
|
-
// remove blank line and comments
|
|
38
|
-
(line) => line.length > 0 && !line.startsWith('#'))
|
|
39
|
-
.map((line) => {
|
|
40
|
-
const { bang, slash, glob } = line.match(/^(?<bang>!?)(?<slash>\/?)(?<glob>.*)$/).groups;
|
|
41
|
-
const hasSlash = Boolean(slash) || /\/.*\S/.test(glob);
|
|
42
|
-
const relativeGlob = path_1.default.posix.join(currentDirectory.replace(
|
|
43
|
-
// escape characters with special meaning in glob expressions
|
|
44
|
-
/[*?!# \[\]\\]/g, (char) => '\\' + char),
|
|
45
|
-
// a pattern that doesn't include a slash (not counting a trailing one) matches files in any descendant directory of the current one
|
|
46
|
-
hasSlash ? '' : '**', glob);
|
|
47
|
-
// preserve leading `!` and `/` characters
|
|
48
|
-
return bang + slash + relativeGlob;
|
|
49
|
-
});
|
|
50
|
-
if (debugIgnore) {
|
|
51
|
-
console.debug('at', currentDirectory, 'parsing', fileName, 'obtained globs', globs);
|
|
52
|
-
}
|
|
53
|
-
return globs;
|
|
54
|
-
};
|
|
55
|
-
const isDirectory = (path) => path.endsWith('/');
|
|
56
|
-
exports.isDirectory = isDirectory;
|
|
57
|
-
// Lists files from the file system,
|
|
58
|
-
// converts them into the internal data structure.
|
|
59
|
-
const computeInitialDocument = ({ fullPath }) => {
|
|
60
|
-
// Initialize the document using our data structure for representing files.
|
|
61
|
-
const initialDocument = {
|
|
62
|
-
files: {},
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Stack for recursively traversing directories.
|
|
66
|
-
* @type {string[]}
|
|
67
|
-
*/
|
|
68
|
-
let files = [];
|
|
69
|
-
const ignoreFileMatcher = (0, ignore_1.default)().add(ignoreFilePattern);
|
|
70
|
-
const isIgnoreFile = (fileName) => ignoreFileMatcher.ignores(fileName);
|
|
71
|
-
const unsearchedDirectories = [
|
|
72
|
-
{
|
|
73
|
-
currentDirectory: '.',
|
|
74
|
-
ignore: (0, ignore_1.default)().add(baseIgnore),
|
|
75
|
-
},
|
|
76
|
-
];
|
|
77
|
-
while (unsearchedDirectories.length !== 0) {
|
|
78
|
-
const { currentDirectory, ignore: parentIgnore } = unsearchedDirectories.pop();
|
|
79
|
-
const currentDirectoryPath = path_1.default.join(fullPath, currentDirectory);
|
|
80
|
-
const dirEntries = fs_1.default
|
|
81
|
-
.readdirSync(currentDirectoryPath, {
|
|
82
|
-
withFileTypes: true,
|
|
83
|
-
})
|
|
84
|
-
.filter((dirent) => enableDirectories ? true : dirent.isFile());
|
|
85
|
-
// find .ignore or .gitignore files in the current directory
|
|
86
|
-
const ignoreFiles = dirEntries
|
|
87
|
-
.filter((dirent) => dirent.isFile() && isIgnoreFile(dirent.name))
|
|
88
|
-
.map((file) => file.name);
|
|
89
|
-
let ignore = parentIgnore;
|
|
90
|
-
if (ignoreFiles.length > 0) {
|
|
91
|
-
const globs = ignoreFiles.flatMap((fileName) => parseIgnoreFile(fullPath, currentDirectory, fileName));
|
|
92
|
-
ignore = (0, ignore_1.default)().add(parentIgnore).add(globs);
|
|
93
|
-
}
|
|
94
|
-
const newFiles = dirEntries
|
|
95
|
-
.filter((dirent) => {
|
|
96
|
-
const relativePath = path_1.default.posix.join(currentDirectory, dirent.name) +
|
|
97
|
-
(dirent.isDirectory() ? '/' : '');
|
|
98
|
-
const keep = !ignore.ignores(relativePath);
|
|
99
|
-
if (debugIgnore && !keep) {
|
|
100
|
-
console.debug('at', currentDirectory, 'ignoring', relativePath);
|
|
101
|
-
}
|
|
102
|
-
return keep;
|
|
103
|
-
})
|
|
104
|
-
// Add a trailing slash for directories
|
|
105
|
-
.map((dirent) => {
|
|
106
|
-
const relativePath = path_1.default.posix.join(currentDirectory, dirent.name);
|
|
107
|
-
if (!dirent.isDirectory()) {
|
|
108
|
-
return relativePath;
|
|
109
|
-
}
|
|
110
|
-
unsearchedDirectories.push({
|
|
111
|
-
currentDirectory: relativePath,
|
|
112
|
-
ignore,
|
|
113
|
-
});
|
|
114
|
-
return relativePath + '/';
|
|
115
|
-
});
|
|
116
|
-
files.push(...newFiles);
|
|
117
|
-
}
|
|
118
|
-
files.forEach((file) => {
|
|
119
|
-
const id = Math.floor(Math.random() * 10000000).toString();
|
|
120
|
-
initialDocument.files[id] = {
|
|
121
|
-
text: (0, exports.isDirectory)(file)
|
|
122
|
-
? null
|
|
123
|
-
: fs_1.default.readFileSync(path_1.default.join(fullPath, file), 'utf-8'),
|
|
124
|
-
name: file,
|
|
125
|
-
};
|
|
126
|
-
});
|
|
127
|
-
if (debugDirectories) {
|
|
128
|
-
console.log('files:');
|
|
129
|
-
console.log(files);
|
|
130
|
-
console.log('initialDocument:');
|
|
131
|
-
console.log(JSON.stringify(initialDocument, null, 2));
|
|
132
|
-
}
|
|
133
|
-
return initialDocument;
|
|
134
|
-
};
|
|
135
|
-
exports.computeInitialDocument = computeInitialDocument;
|