mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-07-24 00:45:23 +02:00
Merger conflict resolution
This commit is contained in:
parent
80d0c2514e
commit
5e84d69aee
3 changed files with 47 additions and 6 deletions
10
bots/codeChackTemplate.js
Normal file
10
bots/codeChackTemplate.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
import * as skills from '../../../src/agent/library/skills.js';
|
||||
import * as world from '../../../src/agent/library/world.js';
|
||||
import Vec3 from 'vec3';
|
||||
|
||||
const log = skills.log;
|
||||
|
||||
export async function main(bot) {
|
||||
/* CODE HERE */
|
||||
log(bot, 'Code finished.');
|
||||
}
|
25
eslint.config.js
Normal file
25
eslint.config.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
// eslint.config.js
|
||||
import globals from "globals";
|
||||
import pluginJs from "@eslint/js";
|
||||
|
||||
/** @type {import('eslint').Linter.Config[]} */
|
||||
export default [
|
||||
// 首先引入推荐配置
|
||||
pluginJs.configs.recommended,
|
||||
|
||||
// 然后覆盖或自定义特定规则
|
||||
{
|
||||
languageOptions: {
|
||||
globals: globals.browser,
|
||||
ecmaVersion: 2021,
|
||||
sourceType: "module",
|
||||
},
|
||||
rules: {
|
||||
"no-undef": "error", // 禁止使用未声明的变量或函数。
|
||||
"semi": ["error", "always"], // 强制在语句末尾使用分号。
|
||||
"curly": "warn", // 强制使用花括号包裹代码块。
|
||||
"no-unused-vars": "off", // 禁用未使用变量的警告。
|
||||
"no-unreachable": "off", // 禁用无法到达代码的警告。
|
||||
},
|
||||
},
|
||||
];
|
|
@ -14,6 +14,7 @@ export class Coder {
|
|||
this.executing = false;
|
||||
this.generating = false;
|
||||
this.code_template = '';
|
||||
this.code_chack_template = '';
|
||||
this.timedout = false;
|
||||
this.cur_action_name = '';
|
||||
|
||||
|
@ -21,7 +22,10 @@ export class Coder {
|
|||
if (err) throw err;
|
||||
this.code_template = data;
|
||||
});
|
||||
|
||||
readFile('./bots/codeChackTemplate.js', 'utf8', (err, data) => {
|
||||
if (err) throw err;
|
||||
this.code_chack_template = data;
|
||||
});
|
||||
mkdirSync('.' + this.fp, { recursive: true });
|
||||
}
|
||||
|
||||
|
@ -64,6 +68,7 @@ export class Coder {
|
|||
for (let line of code.split('\n')) {
|
||||
src += ` ${line}\n`;
|
||||
}
|
||||
let src_check_copy = this.code_chack_template.replace('/* CODE HERE */', src);
|
||||
src = this.code_template.replace('/* CODE HERE */', src);
|
||||
|
||||
let filename = this.file_counter + '.js';
|
||||
|
@ -92,8 +97,7 @@ export class Coder {
|
|||
console.error('Error writing code execution file: ' + result);
|
||||
return null;
|
||||
}
|
||||
|
||||
return [ main: mainFn ,src];
|
||||
return { func:{main: mainFn}, src_check_copy: src_check_copy };
|
||||
}
|
||||
|
||||
sanitizeCode(code) {
|
||||
|
@ -170,10 +174,12 @@ export class Coder {
|
|||
}
|
||||
code = res.substring(res.indexOf('```')+3, res.lastIndexOf('```'));
|
||||
|
||||
let codeStagingResult,src;
|
||||
let codeStagingResult,src_check_copy;
|
||||
try {
|
||||
[codeStagingResult,src] = await this.stageCode(code);
|
||||
const analysisResult = await this.checkCode(src);
|
||||
const result = await this.stageCode(code);
|
||||
codeStagingResult = result.func;
|
||||
src_check_copy = result.src_check_copy;
|
||||
const analysisResult = await this.checkCode(src_check_copy);
|
||||
if (analysisResult) {
|
||||
const message = 'Error: Code syntax error. Please try again:'+'\n'+analysisResult+'\n'+await this.agent.prompter.getRelevantSkillDocs(analysisResult,3);
|
||||
messages.push({ role: 'system', content: message });
|
||||
|
|
Loading…
Add table
Reference in a new issue